Skip to content

Commit 9f5e0c4

Browse files
committed
regression test readme
1 parent b376087 commit 9f5e0c4

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

test/regression/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
- When adding a new test, add variables containing patterns to
26+
replace and modify this function to do the replacement
27+
28+
- `run_sort`: runs the given command, printing the command as well
29+
as the sorted output, passed into `replace`
30+
31+
- `run_no_sort`: runs the given command, printing the command as
32+
well as the unsorted output, passed into `replace`
33+
34+
- `setup_cleanup`: function that is called on exit of script
35+
- Wrap this with a test-specific cleanup function if the test
36+
requires custom cleanup
37+
38+
- `generatetree.sh` generates a fixed tree with known properties
39+
- This is the most commonly used script/tree
40+
41+
- `rollup_tree.sh` generates a fixed tree with known properties for
42+
testing rollups with
43+
- Requires `sudo`
44+
45+
- `gufi_tool.py` fakes entry points into Python tools in order to use
46+
a test configuration file instead of the real one
47+
48+
## Test Script Structure
49+
1. `#!/usr/bin/env bash`
50+
2. License
51+
3. `set -e`
52+
4. `. setup.sh 1`
53+
- Pass in `0` if the source tree and index do not need to be generated
54+
5. Define variables
55+
6. If necessary, set up a cleanup exit function and call it
56+
- Call `setup_cleanup` in this function
57+
7. Define the name where the output will be written to
58+
- `OUTPUT="<name>.out"`
59+
8. Define functions
60+
9. Run tests in a subshell
61+
- `tee` all output to `"${OUTPUT}"`
62+
10. `@DIFF@ @CMAKE_CURRENT_BINARY_DIR@/<name>.expected "${OUTPUT}"`
63+
11. `rm "${OUTPUT}"`
64+
- This only happens if diff returned 0
65+
66+
## Adding a New Test Script
67+
1. Create an empty test script with the name `<name>.sh.in` in this directory
68+
2. Create an empty .expected file in this directory
69+
3. Add the test script and expected file to git
70+
4. Add `<name>` to the appropriate location in `CMakeLists.txt`
71+
6. Add contents into the test script
72+
- See [Test Script Structure](#test-script-structure)
73+
5. Rebuild to get the latest test script into the build directory
74+
- Will be called `<name>.sh`
75+
7. Run the test script until satisfied with the output
76+
8. Overwrite the source .expected file with `<name>.output`
77+
9. If available, run `make shellcheck` to find issues in the test script
78+
10. Commit and push

0 commit comments

Comments
 (0)