Enabletest
Created by: tammojan
Merge request reports
Activity
272 264 273 target_link_libraries(runtests ${EXTRA_LIBRARIES} ${LOFAR_STATION_RESPONSE_LIB}) 274 275 # Add each test as a cmake test (only for tests added with BOOST_AUTO_TEST_SUITE and BOOST_AUTO_TEST_CASE) 276 foreach(TEST_FILENAME ${TEST_FILENAMES}) 277 file(READ ${TEST_FILENAME} TEST_FILE_CONTENTS) 278 279 # Extract test suite name 280 string(REGEX MATCHALL "BOOST_AUTO_TEST_CASE\\( *([A-Za-z_0-9]+) *\\)" FOUND_TESTS ${TEST_FILE_CONTENTS}) 281 string(REGEX MATCH "BOOST_AUTO_TEST_SUITE\\(*([A-Za-z_0-9]+)*\\)" TESTSUITE_NAME_FULL ${TEST_FILE_CONTENTS}) 282 283 # Extract test name 284 string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+) *\\).*" "\\1" TESTSUITE_NAME ${TESTSUITE_NAME_FULL}) 285 foreach(FOUND_TEST ${FOUND_TESTS}) 286 string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+) *\\).*" "\\1" TEST_NAME ${FOUND_TEST}) 287 add_test(NAME "${TESTSUITE_NAME}.${TEST_NAME}" COMMAND runtests --run_test=${TESTSUITE_NAME}/${TEST_NAME} --catch_system_error=yes) Created by: aroffringa
The tests don't depend on runtests now, if I do this:
rm build cd build make test
I get:
$ make test Running tests... Test project /home/anoko/projects/DP3/build Start 1: mirror.add Could not find executable /home/anoko/projects/DP3/build/runtests Looked in the following places: /home/anoko/projects/DP3/build/runtests /home/anoko/projects/DP3/build/runtests /home/anoko/projects/DP3/build/Release/runtests /home/anoko/projects/DP3/build/Release/runtests /home/anoko/projects/DP3/build/Debug/runtests /home/anoko/projects/DP3/build/Debug/runtests /home/anoko/projects/DP3/build/MinSizeRel/runtests /home/anoko/projects/DP3/build/MinSizeRel/runtests /home/anoko/projects/DP3/build/RelWithDebInfo/runtests /home/anoko/projects/DP3/build/RelWithDebInfo/runtests /home/anoko/projects/DP3/build/Deployment/runtests /home/anoko/projects/DP3/build/Deployment/runtests /home/anoko/projects/DP3/build/Development/runtests /home/anoko/projects/DP3/build/Development/runtests home/anoko/projects/DP3/build/runtests home/anoko/projects/DP3/build/runtests home/anoko/projects/DP3/build/Release/runtests home/anoko/projects/DP3/build/Release/runtests home/anoko/projects/DP3/build/Debug/runtests home/anoko/projects/DP3/build/Debug/runtests home/anoko/projects/DP3/build/MinSizeRel/runtests home/anoko/projects/DP3/build/MinSizeRel/runtests home/anoko/projects/DP3/build/RelWithDebInfo/runtests home/anoko/projects/DP3/build/RelWithDebInfo/runtests home/anoko/projects/DP3/build/Deployment/runtests home/anoko/projects/DP3/build/Deployment/runtests home/anoko/projects/DP3/build/Development/runtests home/anoko/projects/DP3/build/Development/runtests Unable to find executable: /home/anoko/projects/DP3/build/runtests
...and a lot more of those errors.
272 264 273 target_link_libraries(runtests ${EXTRA_LIBRARIES} ${LOFAR_STATION_RESPONSE_LIB}) 274 275 # Add each test as a cmake test (only for tests added with BOOST_AUTO_TEST_SUITE and BOOST_AUTO_TEST_CASE) 276 foreach(TEST_FILENAME ${TEST_FILENAMES}) 277 file(READ ${TEST_FILENAME} TEST_FILE_CONTENTS) 278 279 # Extract test suite name 280 string(REGEX MATCHALL "BOOST_AUTO_TEST_CASE\\( *([A-Za-z_0-9]+) *\\)" FOUND_TESTS ${TEST_FILE_CONTENTS}) 281 string(REGEX MATCH "BOOST_AUTO_TEST_SUITE\\(*([A-Za-z_0-9]+)*\\)" TESTSUITE_NAME_FULL ${TEST_FILE_CONTENTS}) 282 283 # Extract test name 284 string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+) *\\).*" "\\1" TESTSUITE_NAME ${TESTSUITE_NAME_FULL}) 285 foreach(FOUND_TEST ${FOUND_TESTS}) 286 string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+) *\\).*" "\\1" TEST_NAME ${FOUND_TEST}) 287 add_test(NAME "${TESTSUITE_NAME}.${TEST_NAME}" COMMAND runtests --run_test=${TESTSUITE_NAME}/${TEST_NAME} --catch_system_error=yes) Created by: tammojan
* `make test` doesn't work without `make check`. I tried to look up in the documentation of how to make the tests depend on runtest but can't find anything that works. A workaround is to put `runtests` in the ALL target (after which `make` followed by `make test` would work, but just `make test` still doesn't work, as apparently that's not supposed to work in cmake ( ? ) ), but I really dislike that, because I don't want to build the tests continuously when developing.
Should be fixed now.
* It adds mostly unnecessary complexity * Searching for `BOOST_AUTO_TEST_CASE` etc in the source code is a bit ugly and limits the use of different Boost tests.
Adds complexity yes, but I hope these 12 lines of CMake code (though ugly) are documented and self-explanatory enough. Other kind of boost tests can be added later on by expanding the regexp.
* The advantage that I see of having the make-test output is small, if any (I like the output of 'make test', but it is not much different from `runtest -l unit_scope`, which executes faster -- but I like the concept of 'no output means no error' which an empty `runtest` would do a bit more, so you don't have to scroll back to see what happened).
This boils down to personal preference. In CTest, there's an option to show output of all failed tests; as well as the option
--quiet
to hide all output except when something fails.The only good reason that I see to use cmake testing, is if the more advanced test cases that use input data can not be covered without using cmake tests. Maybe we should investigate whether that's the case, and if they can be covered just keep it simple and only use Boost testing.
Since all current tests are based on CMake, I don't see a big advantage of rewriting everything into Boost. This hybrid approach enables you to write tests in boost, while it should be more straightforward to enable old cmake tests.