Integrate java unit tests into ctest (#7593)
authorGereon Kremer <nafur42@gmail.com>
Sat, 6 Nov 2021 21:43:43 +0000 (14:43 -0700)
committerGitHub <noreply@github.com>
Sat, 6 Nov 2021 21:43:43 +0000 (14:43 -0700)
This PR properly integrates the java api unit tests into ctest.

src/api/__pycache__/parsekinds.cpython-39.pyc [deleted file]
test/unit/api/java/CMakeLists.txt

diff --git a/src/api/__pycache__/parsekinds.cpython-39.pyc b/src/api/__pycache__/parsekinds.cpython-39.pyc
deleted file mode 100644 (file)
index 34d010c..0000000
Binary files a/src/api/__pycache__/parsekinds.cpython-39.pyc and /dev/null differ
index 61ae74fd28a0b77140ce614c65ab3299a2353287..5f573a1175caf7ddd49cf9eb3651c4d9bd4d370c 100644 (file)
@@ -18,6 +18,7 @@ include(UseJava)
 find_package(JUnit REQUIRED)
 
 get_target_property(CVC5_JAR_PATH cvc5jar JAR_FILE)
+get_filename_component(CVC5_JNI_PATH ${CVC5_JAR_PATH} DIRECTORY)
 
 # specify source files for junit tests
 set(java_test_src_files
@@ -31,9 +32,9 @@ set(java_test_src_files
 )
 
 # build junit tests
-add_custom_target(
-  build-junit-tests
-  ALL
+add_custom_command(
+  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tests/SolverTest.class
+  DEPENDS JUnit-EP-jar cvc5jar ${java_test_src_files}
   COMMAND
     ${Java_JAVAC_EXECUTABLE} ${java_test_src_files}
     -cp ${JUnit_JAR}:${CVC5_JAR_PATH} # add JUnit and cvc5 jar files to the class path
@@ -41,29 +42,28 @@ add_custom_target(
   COMMENT "Build junit tests"
   VERBATIM
 )
-
-# make sure junit jar file is present
-add_dependencies(build-junit-tests JUnit-EP-jar)
-# make sure cvc.jar file is built first
-add_dependencies(build-junit-tests cvc5jar)
-
-get_filename_component(CVC5_JNI_PATH ${CVC5_JAR_PATH} DIRECTORY)
-
-# run junit tests
-add_custom_target(
-  run-junit-tests
-  ALL
-  COMMAND
-    # run junit tests
-    ${Java_JAVA_EXECUTABLE}
-    -Djava.library.path=${CVC5_JNI_PATH}
-    -jar ${JUnit_JAR}
-    -cp ${JUnit_JAR}:${CVC5_JAR_PATH}:.
-    -select-package tests
-  COMMENT "Run junit tests"
-  VERBATIM
+add_custom_target(build-junit-tests
+  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tests/SolverTest.class
 )
+add_dependencies(build-units build-junit-tests)
+
+macro(cvc5_add_java_api_test name)
+  add_test (NAME unit/api/java/${name}
+    COMMAND
+      ${Java_JAVA_EXECUTABLE}
+      -Djava.library.path=${CVC5_JNI_PATH}
+      -jar ${JUnit_JAR}
+      -cp ${JUnit_JAR}:${CVC5_JAR_PATH}:.
+      -select-package tests
+      -n tests.${name}
+  )
+  set_tests_properties(unit/api/java/${name} PROPERTIES LABELS "unit java")
+endmacro()
 
-add_dependencies(run-junit-tests build-junit-tests)
-add_dependencies(units run-junit-tests)
-add_dependencies(check run-junit-tests)
\ No newline at end of file
+cvc5_add_java_api_test(DatatypeTest)
+cvc5_add_java_api_test(GrammarTest)
+cvc5_add_java_api_test(OpTest)
+cvc5_add_java_api_test(ResultTest)
+cvc5_add_java_api_test(SolverTest)
+cvc5_add_java_api_test(SortTest)
+cvc5_add_java_api_test(TermTest)