diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index c1e3eed7a2..65c3a66d28 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -88,20 +88,23 @@ target_include_directories( unit_test PUBLIC add_test(NAME protocol_feature_digest_unit_test COMMAND unit_test --run_test=protocol_feature_digest_tests --report_level=detailed --color_output) set(ctest_tests "protocol_feature_digest_tests") foreach(TEST_SUITE ${UNIT_TESTS}) # create an independent target for each test suite - execute_process(COMMAND sh -c "grep -E 'BOOST_AUTO_TEST_SUITE\\s*[(]' '${TEST_SUITE}' | grep -vE '//.*BOOST_AUTO_TEST_SUITE\\s*[(]' | cut -d ')' -f 1 | cut -d '(' -f 2" OUTPUT_VARIABLE SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # get the test suite name from the *.cpp file - if (NOT "" STREQUAL "${SUITE_NAME}") # ignore empty lines - execute_process(COMMAND sh -c "echo ${SUITE_NAME} | sed -e 's/s$//' | sed -e 's/_test$//'" OUTPUT_VARIABLE TRIMMED_SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # trim "_test" or "_tests" from the end of ${SUITE_NAME} - # to run unit_test with all log from blockchain displayed, put "--verbose" after "--", i.e. "unit_test -- --verbose" - foreach(RUNTIME ${EOSIO_WASM_RUNTIMES}) - add_test(NAME ${TRIMMED_SUITE_NAME}_unit_test_${RUNTIME} COMMAND unit_test --run_test=${SUITE_NAME} --report_level=detailed --color_output -- --${RUNTIME}) - # build list of tests to run during coverage testing - if(ctest_tests) - string(APPEND ctest_tests "|") - endif() - string(APPEND ctest_tests ${TRIMMED_SUITE_NAME}_unit_test_$RUNTIME) - endforeach() - endif() -endforeach(TEST_SUITE) + execute_process(COMMAND sh -c "grep -E 'BOOST_AUTO_TEST_SUITE\\s*[(]' '${TEST_SUITE}' | grep -vE '//.*BOOST_AUTO_TEST_SUITE\\s*[(]' | cut -d ')' -f 1 | cut -d '(' -f 2" OUTPUT_VARIABLE SUITE_NAMES OUTPUT_STRIP_TRAILING_WHITESPACE) # get the test suite name from the *.cpp file + string(REPLACE "\n" ";" SUITE_NAMES "${SUITE_NAMES}") + foreach(SUITE_NAME IN LISTS SUITE_NAMES) + if (NOT "" STREQUAL "${SUITE_NAME}") # ignore empty lines + execute_process(COMMAND sh -c "echo ${SUITE_NAME} | sed -e 's/s$//' | sed -e 's/_test$//'" OUTPUT_VARIABLE TRIMMED_SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # trim "_test" or "_tests" from the end of ${SUITE_NAME} + # to run unit_test with all log from blockchain displayed, put "--verbose" after "--", i.e. "unit_test -- --verbose" + foreach(RUNTIME ${EOSIO_WASM_RUNTIMES}) + add_test(NAME ${TRIMMED_SUITE_NAME}_unit_test_${RUNTIME} COMMAND unit_test --run_test=${SUITE_NAME} --report_level=detailed --color_output -- --${RUNTIME}) + # build list of tests to run during coverage testing + if(ctest_tests) + string(APPEND ctest_tests "|") + endif() + string(APPEND ctest_tests ${TRIMMED_SUITE_NAME}_unit_test_$RUNTIME) + endforeach() + endif() + endforeach() +endforeach() set(ctest_tests "'${ctest_tests}' -j8") # surround test list string in apostrophies # The following tests are known to take the longest, bump up their cost (priority) so that they'll run first