Skip to content

Update tests, including Catch version

Sacha Duverger requested to merge update/tests into custom_cbgeo

This MR updates the testing scripts that were made by the CB-Geo research group on their branch (develop).

What needed to be done

  • update the testing library (Catch). It used to be located in the external directory, but now requires to be installed with apt-get install catch2. This was necessary to avoid compilation errors.
  • update the usage of many functions according to the changes we made on our fork
  • solve assertion issues, presumably brought by Catch2. These included 1) the assertions that a value is 0 does not work like any other floats (see this Catch2 issue for more details) and 2) the slight increase of some tolerance values with which tests didn't work as expected (see for instance tests in tests/materials/mohr_coulomb_test.cc)
  • solve issues related to the MPI usage. Some tests assumed the code was compiled using MPI, they are now performed only if MPI is used.
  • adapt the usage of compute_updated_position, which does not update the particle velocity anymore (now it is compute_particle_velocity job)

What remains to do

  • make it so tests do not raise errors. These errors are to be expected since functions are not used in the same context than during a simulation, and should thus be ignored. I don't like that, it is confusing and floods the output, so I will try to solve it DONE
  • add tests for new features from our fork DONE
  • improve the testing handling in the CMakeLists.txt DONE. Maybe also try, in this file, to import scripts recursively rather than one by one explicitly (there must be a better way) EDIT: turns out the latter is possible but not recommended, so I'm leaving this as is
  • add testing to the CI pipeline DONE
  • update README.md with new instructions: 1) necessity of installing Catch2 with apt (only if the user wants to run the tests) 2) instruction on how to run the tests DONE
  • clean up the output of the tests (by adding an option to write the output to a file ?) DONE
  • organize better the input files necessary (and generated) for the tests, currently at the root of the build directory DONE

How to run the tests

As for now (this should change soon), to run the tests one has to compile with the CMake option WITH_TESTS set to ON (e.g. using -DWITH_TESTS=ON with cmake), and then execute the tests executable, currently named ${EXECUTABLE_NAME}-test (default mpm-test) and only located in the build directory (it is not installed in INSTALL_DIR, and depends on files in the build directory). No error should be raised, but a fairly large amount of output is to be expected. At the end, one should see:

===============================================================================
All tests passed (20462 assertions in 70 test cases)
Edited by Sacha Duverger

Merge request reports