Skip to content

Commit ea34ff7

Browse files
authored
Update TESTING.md for ctest
1 parent 3a7ebcc commit ea34ff7

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

TESTING.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
# Unit Testing
22

3-
FMS includes a suite of MPI unit tests using the testing infrastructure included in the GNU autotools build system
4-
in order to check the functionality of the library's modules.
3+
FMS includes a suite of MPI unit tests for most subdirectories and modules that make up the library.
54

65
It consists of programs in the test_fms/ directory, with shell scripts to handle directory set up and input files.
76
test_lib.sh.in and tap-driver.sh provide additional helper functions used in the scripts and manage output.
87

8+
The unit tests can be run either through the autotools build system, or through cmake via ctest.
9+
The different build systems will run the exact same scripts and executables, but there are some differences in the commands used to start the testing.
10+
11+
## Autotools Unit Testing
12+
913
### Running the Tests
1014

11-
1. Configure with autotools
15+
1. Configure and build the code with autotools
1216
```
1317
mkdir build # create a build directory in FMS
18+
cd build
1419
autoreconf -if ../configure.ac
1520
../configure <configure options>
21+
make
1622
```
1723

1824
2. Build and run suite
@@ -21,7 +27,7 @@ make check
2127
```
2228
This will compile any code not already compiled and then proceed to run the test scripts.
2329

24-
### Debugging Output and Test Options
30+
### Debugging Output and Test Options for Autotools
2531

2632
Setting the environment variable TEST_VERBOSE will direct output to stdout as the test runs, while setting VERBOSE will only output on failure.
2733
Logs are created for each test as well, with the name \<test script name\>.log in its corresponding test_fms/ directory.
@@ -44,3 +50,36 @@ for the build system:
4450
- `--enable-test-input=/path/to/input` turns on test scripts that require input netcdf files (interpolator, xgrid, data_override).
4551
This option is mainly used internally and in automated testing since we do not host the input data publicly.
4652
- `--with-yaml` compile with yaml input and enable its associated tests
53+
54+
## CMake Unit Testing
55+
56+
### Running the tests
57+
58+
1. Configure and build the code and tests with cmake
59+
```
60+
mkdir build
61+
cd build
62+
cmake <Any cmake options such as -DWITH_YAML=on> ..
63+
make
64+
```
65+
2. Run the tests with ctest
66+
```
67+
ctest
68+
```
69+
Alternatively, the generated makefile can be used as well:
70+
```
71+
make test
72+
```
73+
### Debugging and Test Options for CMake
74+
75+
All tests are labeled with the subdirectory they are in in the `test_fms` directory.
76+
To run tests for a specific area of the code, such as the mpp modules:
77+
```
78+
ctest -L mpp
79+
```
80+
To rerun failed tests with debug output from a previous failed ctest command:
81+
```
82+
ctest --rerun-failed --verbose
83+
```
84+
85+
For more testing options with ctest, you can look to the [ctest documentation]().

0 commit comments

Comments
 (0)