-
Notifications
You must be signed in to change notification settings - Fork 20
Tests
Ant uses the Catch framework for unit-tests for a test-driven development. The tests are organized in the test/ subdirectory.
The idea for developing Ant is using continuous integration. This means the development takes place in a shared mainline where changes are pushed several times a day. Each time commits are pushed to the main branch in Ant a Webhook is triggered which starts an automated build process. Within the Ant repository Travis CI is used for this task. The corresponding configuration files are stored in the ci/ subdirectory.
To improve the management of the various components needed for Ant, the packages are maintained in a separate repository.
A test can be added by writing a test class. In this test class different methods can be added to test the various procedures in the existing code base. In these methods you typacilly know what the result should be which is checked with the REQUIRE
macro. If the condition in REQUIRE
is false, the test fails. The methods for testing are called with the TEST_CASE
macro. A short tutorial can be found here. A short example test for Ant could be TestAntReader which checks the content of an unpacked event.
New tests can be easily added to the testing process by adding it to the CMakeLists.txt
in the corresponding subdirectory via the add_ant_test()
method.
To run the tests you can run make build_and_test
while standing in your build-folder. This builds all the tests and runs them in succession.
If you want to run only a single test, you can build it with e.g. make test_analysis_AntReader
, where test_
means it's a test, followed by the subdirectory (analysis) and the name of the test used in the add_ant_test()
method. This creates a binary analysis_AntReader
in the bin_test
folder in your build directory. So running this single test is done by calling bin_test/analysis_AntReader
.
Travis provides several virtualisation environments the triggered build can be run in. For the current Ant configuration the Ubuntu Trusty one is used. This comes with a maximum memory of 4GB. So if you introduce lots of histograms or just one or two really big ones you might exceed this limit. If this happens, the process gets killed and nothing useful will be shown in the build log. To speed up the tests, we run always two test in parallel. This means even though you're class might only need let's say 3GB running your physics class, but another test is run in parallel using slightly less than 1GB, the limit is hit already since the system itself needs some memory as well. Keep this in mind if you see the build failing without any obvious reason after adding histograms or other memory extensive stuff. Even if make build_and_test
runs without any issues on your machine.