Skip to content

Commit 3116b34

Browse files
authored
Add the option to test without testing cases in examples/ (#753)
1 parent 0f21835 commit 3116b34

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

docs/documentation/testing.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Testing
2-
2+
33
To run MFC's test suite, run
44
```shell
55
./mfc.sh test -j <thread count>
@@ -8,15 +8,15 @@ To run MFC's test suite, run
88
It will generate and run test cases, comparing their output to previous runs from versions of MFC considered accurate.
99
*golden files*, stored in the `tests/` directory contain this data, aggregating `.dat` files generated when running MFC.
1010
A test is considered passing when our error tolerances are met in order to maintain a high level of stability and accuracy.
11-
Run `./mfc.sh test -h` for a full list of accepted arguments.
12-
13-
Most notably, you can consult the full list of tests by running
14-
```shell
15-
./mfc.sh test -l
16-
```
11+
`./mfc.sh test` has the following unique options:
12+
- `-l` outputs the full list of tests
13+
- `--from` (`-f)` and `--to` (`t`) restrict testing to a range of contiguous slugs
14+
- `--only` (`-o`) restricts testing to a non-contiguous range of tests based on if their trace contains a certain feature
15+
- `--test-all` (`a`) test post process and ensure the Silo database files are correct
16+
- `--percent` (`%`) to specify a percentage of the test suite to select at random and test
17+
- `--max-attempts` (`-m`) the maximum number of attempts to make on a test before considering it failed
18+
- `--no-examples` skips the testing of cases in the examples folder
1719

18-
To restrict to a given range, use the `--from` (`-f`) and `--to` (`-t`) options.
19-
To run a (non-contiguous) subset of tests, use the `--only` (`-o`) option instead.
2020
To specify a computer, pass the `-c` flag to `./mfc.sh run` like so:
2121
```shell
2222
./mfc.sh test -j <thread count> -- -c <computer name>
@@ -27,15 +27,13 @@ The use of `--` in the above command passes options to the `./mfc.sh run` comman
2727

2828
### Creating Tests
2929

30-
To (re)generate *golden files*, append the `--generate` option:
31-
```shell
32-
./mfc.sh test --generate -j 8
33-
```
30+
Creating and updating test cases can be done with the following command line arguments:
31+
- `--generate` to generate golden files for a new test case
32+
- `--add-new-variables` to similar to `--generate`, but rather than generating a golden file from scratch, it generates a gold file with new variables for an updated test without changing the original golden file values.
33+
- `--remove-old-tests` to remove the directories of tests that no longer exist
3434

3535
It is recommended that a range be specified when generating golden files for new test cases, as described in the previous section, in an effort not to regenerate the golden files of existing test cases.
3636

37-
**Note:** If you output new variables and want to update the golden files to include these without modifying the original data, use the `--add-new-variables` option instead.
38-
3937
Adding a new test case can be done by modifying [cases.py](https://github.com/MFlowCode/MFC/tree/master/toolchain/mfc/test/cases.py).
4038
The function `list_cases` is responsible for generating the list of test cases.
4139
Loops and conditionals are used to vary parameters, whose defaults can be found in the `BASE_CFG` case object within [case.py](https://github.com/MFlowCode/MFC/tree/master/toolchain/mfc/test/case.py).
@@ -44,7 +42,7 @@ The function operates on two variables:
4442
- `stack`: A stack that holds the variations to the default case parameters.
4543
By pushing and popping the stack inside loops and conditionals, it is easier to nest test case descriptions, as it holds the variations that are common to all future test cases within the same indentation level (in most scenarios).
4644

47-
- `cases`: A list that holds fully-formed `Case` objects, that will be returned at the end of the function.
45+
- `cases`: A list that holds fully-formed `Case` objects, that will be returned at the end of the function.
4846

4947
Internally a test case is described as:
5048
```python
@@ -93,13 +91,13 @@ Finally, the case is appended to the `cases` list, which will be returned by the
9391

9492
### Testing Post Process
9593

96-
To test the post-processing code, append the `-a` or `--test-all` option:
94+
To test the post-processing code, append the `-a` or `--test-all` option:
9795
```shell
9896
./mfc.sh test -a -j 8
9997
```
10098

10199
This argument will re-run the test stack with `parallel_io='T'`, which generates silo_hdf5 files.
102100
It will also turn most write parameters (`*_wrt`) on.
103101
Then, it searches through the silo files using `h5dump` to ensure that there are no `NaN`s or `Infinity`s.
104-
Although adding this option does not guarantee that accurate `.silo` files are generated, it does ensure that the post-process code does not fail or produce malformed data.
102+
Although adding this option does not guarantee that accurate `.silo` files are generated, it does ensure that the post-process code does not fail or produce malformed data.
105103

toolchain/mfc/args.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def add_common_arguments(p, mask = None):
8181
test.add_argument("-%", "--percent", type=int, default=100, help="Percentage of tests to run.")
8282
test.add_argument("-m", "--max-attempts", type=int, default=1, help="Maximum number of attempts to run a test.")
8383
test.add_argument( "--no-build", action="store_true", default=False, help="(Testing) Do not rebuild MFC.")
84+
test.add_argument( "--no-examples", action="store_true", default=False, help="Do not test example cases." )
8485
test.add_argument("--case-optimization", action="store_true", default=False, help="(GPU Optimization) Compile MFC targets with some case parameters hard-coded.")
8586
test_meg = test.add_mutually_exclusive_group()
8687
test_meg.add_argument("--generate", action="store_true", default=False, help="(Test Generation) Generate golden files.")

toolchain/mfc/state.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def __str__(self) -> str:
5050
gCFG: MFCConfig = MFCConfig()
5151
gARG: dict = {}
5252

53-
5453
def ARG(arg: str, dflt = None) -> typing.Any:
5554
# pylint: disable=global-variable-not-assigned
5655
global gARG

toolchain/mfc/test/cases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,9 @@ def chemistry_cases():
861861
))
862862

863863
foreach_dimension()
864+
864865
foreach_example()
866+
865867
chemistry_cases()
866868

867869
# Sanity Check 1

toolchain/mfc/test/test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def __filter(cases_) -> typing.List[TestCase]:
5656
cases.remove(case)
5757
skipped_cases.append(case)
5858

59+
if ARG("no_examples"):
60+
cases = [case for case in cases if not "Example" in case.trace]
61+
5962
if ARG("percent") == 100:
6063
return cases, skipped_cases
6164

0 commit comments

Comments
 (0)