From bd866bbf75606663315c15ce4f28862e99b70cbd Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Wed, 26 Sep 2018 15:34:58 -0700 Subject: [PATCH] cmake: Fix test target dependency issues. (#2540) --- CMakeLists.txt | 3 +-- test/CMakeLists.txt | 33 ++++++++++++++++----------------- test/java/CMakeLists.txt | 8 +++++--- test/regress/CMakeLists.txt | 8 +++++++- test/system/CMakeLists.txt | 13 ++++++++----- test/unit/CMakeLists.txt | 14 +++++++++----- 6 files changed, 46 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 921396e21..654e5f3f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,8 +271,7 @@ if(ENABLE_COVERAGE) setup_target_for_coverage_lcov( NAME coverage EXECUTABLE - ctest -j${CTEST_NTHREADS} -LE "example" --output-on-failure $(ARGS) - DEPENDENCIES cvc4-bin) + ctest -j${CTEST_NTHREADS} -LE "example" --output-on-failure $(ARGS)) endif() if(ENABLE_DEBUG_CONTEXT_MM) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 44cf5a651..b85ecf9e7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,19 @@ +#-----------------------------------------------------------------------------# +# Add target 'check', builds and runs +# > unit tests +# > regression tests of levels 0 and 1 +# > system tests + +# Note: Do not add custom targets for running tests (regress, systemtests, +# units) as dependencies to other run targets. This will result in executing +# tests multiple times. For example, if check would depend on regress it would +# first run the command of the regress target (i.e., run all regression tests) +# and afterwards run the command specified for the check target. +# Dependencies of check are added in the corresponding subdirectories. +add_custom_target(check + COMMAND + ctest --output-on-failure -LE "regress[2-4]" -j${CTEST_NTHREADS} $(ARGS)) + #-----------------------------------------------------------------------------# # Add subdirectories @@ -11,20 +27,3 @@ endif() if(ENABLE_UNIT_TESTING) add_subdirectory(unit EXCLUDE_FROM_ALL) endif() - -#-----------------------------------------------------------------------------# -# Add target 'check', builds and runs -# > unit tests -# > regression tests of levels 0 and 1 -# > system tests - -add_custom_target(check - COMMAND - ctest --output-on-failure -LE "regress[2-4]" -j${CTEST_NTHREADS} $(ARGS) - DEPENDS regress systemtests) -if(BUILD_BINDINGS_JAVA) - add_dependencies(check cvc4javatests) -endif() -if(ENABLE_UNIT_TESTING) - add_dependencies(check units) -endif() diff --git a/test/java/CMakeLists.txt b/test/java/CMakeLists.txt index 27042559a..b6f0d035a 100644 --- a/test/java/CMakeLists.txt +++ b/test/java/CMakeLists.txt @@ -10,16 +10,18 @@ set(java_test_src_files LinearArith.java ) -add_jar(cvc4javatests +add_jar(build-javatests SOURCES ${java_test_src_files} INCLUDE_JARS ${CMAKE_BINARY_DIR}/src/bindings/java/CVC4.jar ${JUnit_JAR} + OUTPUT_NAME javatests ) -add_dependencies(cvc4javatests cvc4jar) +add_dependencies(build-javatests cvc4jar) +add_dependencies(check build-javatests) # Add java tests to ctest -set(classpath "${CMAKE_CURRENT_BINARY_DIR}/cvc4javatests.jar") +set(classpath "${CMAKE_CURRENT_BINARY_DIR}/javatests.jar") set(classpath "${classpath}:${CMAKE_BINARY_DIR}/src/bindings/java/CVC4.jar") set(classpath "${classpath}:${JUnit_JAR}:${JUnit_JAR_DEPS}") diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index 3f6aa7956..35672d77a 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -2075,10 +2075,16 @@ set(regression_disabled_tests get_target_property(path_to_cvc4 cvc4-bin RUNTIME_OUTPUT_DIRECTORY) set(run_regress_script ${CMAKE_CURRENT_LIST_DIR}/run_regression.py) +add_custom_target(build-regress DEPENDS cvc4-bin) +add_dependencies(check build-regress) +if(ENABLE_COVERAGE) + add_dependencies(coverage build-regress) +endif() + add_custom_target(regress COMMAND ctest --output-on-failure -L "regress[0-1]" -j${CTEST_NTHREADS} $(ARGS) - DEPENDS cvc4-bin) + DEPENDS build-regress) macro(cvc4_add_regression_test level file) add_test(${file} diff --git a/test/system/CMakeLists.txt b/test/system/CMakeLists.txt index 1832217c3..36e6c4a37 100644 --- a/test/system/CMakeLists.txt +++ b/test/system/CMakeLists.txt @@ -7,9 +7,15 @@ include_directories(${CMAKE_BINARY_DIR}/src) # Add target 'systemtests', builds and runs # > system tests +add_custom_target(build-systemtests) +add_dependencies(check build-systemtests) +if(ENABLE_COVERAGE) + add_dependencies(coverage build-systemtests) +endif() + add_custom_target(systemtests COMMAND ctest --output-on-failure -L "system" -j${CTEST_NTHREADS} $(ARGS) - DEPENDS main-test) + DEPENDS build-systemtests) set(CVC4_SYSTEM_TEST_FLAGS -D__BUILDING_CVC4_SYSTEM_TEST -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS) @@ -20,10 +26,7 @@ macro(cvc4_add_system_test name) target_compile_definitions(${name} PRIVATE ${CVC4_SYSTEM_TEST_FLAGS}) add_test(system/${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}) set_tests_properties(system/${name} PROPERTIES LABELS "system") - add_dependencies(systemtests ${name}) - if(ENABLE_COVERAGE) - add_dependencies(coverage ${name}) - endif() + add_dependencies(build-systemtests ${name}) endmacro() cvc4_add_system_test(boilerplate) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 3d1007929..4bcb97c8e 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -7,8 +7,15 @@ include_directories(${CMAKE_BINARY_DIR}/src) # Add target 'units', builds and runs # > unit tests +add_custom_target(build-units) +add_dependencies(check build-units) +if(ENABLE_COVERAGE) + add_dependencies(coverage build-units) +endif() + add_custom_target(units - COMMAND ctest --output-on-failure -L "unit" -j${CTEST_NTHREADS} $(ARGS)) + COMMAND ctest --output-on-failure -L "unit" -j${CTEST_NTHREADS} $(ARGS) + DEPENDS build-units) set(CVC4_CXXTEST_FLAGS_BLACK -D__BUILDING_CVC4LIB_UNIT_TEST -D__BUILDING_CVC4PARSERLIB_UNIT_TEST @@ -46,7 +53,7 @@ macro(cvc4_add_unit_test is_white name output_dir) # Disable the Wsuggest-override warnings for the unit tests. CxxTest generates # code that does not properly add the override keyword to runTest(). target_compile_options(${name} PRIVATE -Wno-suggest-override) - add_dependencies(units ${name}) + add_dependencies(build-units ${name}) # Generate into bin/test/unit/. set(test_bin_dir ${CMAKE_BINARY_DIR}/bin/test/unit/${output_dir}) set_target_properties(${name} @@ -62,9 +69,6 @@ macro(cvc4_add_unit_test is_white name output_dir) endif() add_test(${test_name} ${test_bin_dir}/${name}) set_tests_properties(${test_name} PROPERTIES LABELS "unit") - if(ENABLE_COVERAGE) - add_dependencies(coverage ${name}) - endif() endmacro() macro(cvc4_add_unit_test_black name output_dir) -- 2.30.2