cmake: Fix test target dependency issues. (#2540)
authorMathias Preiner <mathias.preiner@gmail.com>
Wed, 26 Sep 2018 22:34:58 +0000 (15:34 -0700)
committerAina Niemetz <aina.niemetz@gmail.com>
Wed, 26 Sep 2018 22:34:58 +0000 (15:34 -0700)
CMakeLists.txt
test/CMakeLists.txt
test/java/CMakeLists.txt
test/regress/CMakeLists.txt
test/system/CMakeLists.txt
test/unit/CMakeLists.txt

index 921396e2183f11a4644acaae125fdb864f2858bc..654e5f3f27aa641fe8e00cf4bcf89000466f2a3a 100644 (file)
@@ -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)
index 44cf5a6517b8c6c942ba21de01d2734662698fe2..b85ecf9e774a2fb421698d6d48b590cc3589ef31 100644 (file)
@@ -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()
index 27042559a4a90eb7d463ee3e70156f3177a3046d..b6f0d035a2576a9fd9ac3e1aa8a41682a39a5b5c 100644 (file)
@@ -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}")
 
index 3f6aa79566672c6136ad0ee0dbc7b057b8e107a6..35672d77a9fe27373f3033eb618b6e20c13c3210 100644 (file)
@@ -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}
index 1832217c3db16e8254ae7a4b76304eca21a77a82..36e6c4a37330a7f62ec6fbbde652e7ff601c17e2 100644 (file)
@@ -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)
index 3d1007929047a925d28bfa67253c374df0e797c0..4bcb97c8ec7e77790e8069d45962e8af0c23188d 100644 (file)
@@ -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/<output_dir>.
   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)