|
| 1 | +# Regression Tests |
| 2 | + |
| 3 | +This directory contains regression tests for GUFI. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +Each regression test consists of at least two files: a bash script and |
| 8 | +a corresponding .expected file. There might be additional files, such |
| 9 | +as Python scripts, associated with each test. To run a single set of |
| 10 | +tests, run the script file from a directory that allows for extended |
| 11 | +attributes, and it should work. The output will be printed to standard |
| 12 | +out as well as a corresponding .out file. The diff between the |
| 13 | +.expected file and .outfile will also be printed. The regression tests |
| 14 | +can be viewed as known answer tests. |
| 15 | + |
| 16 | +If a regression test's .expected needs to be updated with the latest |
| 17 | +output from the test script, the .out file can be usd to directly |
| 18 | +overwrite the .expected file with `cp`, `mv`, or `cat` and a redirect. |
| 19 | + |
| 20 | +## Common Files |
| 21 | + |
| 22 | +- `setup.sh` contains common functions, variables, cleanup code, etc. |
| 23 | + - `replace`: replaces environment-specific text with common text, |
| 24 | + such as the actual path to an executable with the name |
| 25 | + |
| 26 | + - `run_sort`: runs the given command, printing the command as well |
| 27 | + as the sorted output, passed into `replace` |
| 28 | + |
| 29 | + - `run_no_sort`: runs the given command, printing the command as |
| 30 | + well as the unsorted output, passed into `replace` |
| 31 | + |
| 32 | + - `setup_cleanup`: function that is called on exit of script |
| 33 | + - wrap this with a test-specific cleanup function if the test |
| 34 | + requires custom cleanup |
| 35 | + |
| 36 | +- `generatetree.sh` generates a fixed tree with known properties |
| 37 | + - This is the most commonly used script/tree |
| 38 | + |
| 39 | +- `rollup_tree.sh` generates a fixed tree with known properties for |
| 40 | + testing rollups with |
| 41 | + - Requires `sudo` |
| 42 | + |
| 43 | +- `gufi_tool.py` fakes entry points into Python tools in order to use |
| 44 | + a test configuration file instead of the real one |
| 45 | + |
| 46 | +## Test Script Structure |
| 47 | +1. `set -e` |
| 48 | +2. `. setup.sh 1` |
| 49 | + - Pass in 0 if the source tree and index do not need to be generated |
| 50 | +3. Define variables |
| 51 | +4. If necessary, set up cleanup function and call it |
| 52 | +5. Define the name where the output will be written to |
| 53 | + - `OUTPUT="<name>.out"` |
| 54 | +6. Define functions |
| 55 | +7. Run tests in a subshell |
| 56 | + - `tee` all output to `"${OUTPUT}"` |
| 57 | +8. Diff the expected file with `"${OUTPUT}"` |
| 58 | +9. Remove `"${OUTPUT}"` |
| 59 | + - This only happens if the diff in the previous step succeeded |
0 commit comments