Commit 14ac253a authored by Marc Chevrier's avatar Marc Chevrier

FindJava: tests clean-up

parent a1f78a48
......@@ -3349,81 +3349,45 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink
file(READ "${JNI_H}" JNI_FILE)
if("${JNI_FILE}" MATCHES "JDK1_2")
add_test(Java.Jar ${CMAKE_CTEST_COMMAND}
add_test(NAME Java.Jar COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Java"
"${CMake_BINARY_DIR}/Tests/JavaJar"
${build_generator_args}
--build-project hello
--build-target hello
--build-two-config
--build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/"
--test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar")
add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Java"
"${CMake_BINARY_DIR}/Tests/JavaJarSourceList"
${build_generator_args}
--build-project hello
--build-target hello2
--build-two-config
--build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/"
--test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList")
add_test(Java.JarSourceListAndOutput ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Java"
"${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput"
${build_generator_args}
--build-project hello
--build-target hello3
--build-two-config
--build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput/hello3"
--test-command ${JAVA_RUNTIME} -classpath hello3.jar HelloWorld)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput")
# For next tests, java tool must have same architecture as toolchain
math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8")
execute_process(
COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version
OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result
COMMAND "${Java_JAVA_EXECUTABLE}" -version
OUTPUT_VARIABLE _version ERROR_VARIABLE _version RESULT_VARIABLE _result
)
if(_result EQUAL 0)
if(_result EQUAL 0 AND _version MATCHES "${_object_mode}-Bit")
## next test is valid only if Java version is less than 1.10
if ("${Java_VERSION}" VERSION_LESS 1.10)
if(_isMultiConfig)
set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>)
else()
set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah)
endif()
add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/JavaJavah"
"${CMake_BINARY_DIR}/Tests/JavaJavah"
${build_generator_args}
--build-project helloJavah
--build-two-config
--build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/"
--test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah")
endif()
## next test is valid only if Java is, at least, version 1.8
if (NOT "${Java_VERSION}" VERSION_LESS 1.8)
if(_isMultiConfig)
set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/$<CONFIGURATION>)
else()
set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders)
endif()
add_test(NAME Java.NativeHeaders COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders"
"${CMake_BINARY_DIR}/Tests/JavaNativeHeaders"
${build_generator_args}
--build-project helloJavaNativeHeaders
--build-two-config
--build-run-dir "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/"
--test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVANATIVEHEADERS_LIBRARY_PATH} -classpath hello4.jar HelloWorld3)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders")
endif()
endif()
......
......@@ -3,6 +3,8 @@ project(hello Java)
cmake_minimum_required (VERSION 2.6)
set(CMAKE_VERBOSE_MAKEFILE 1)
include(CTest)
find_package(Java COMPONENTS Development)
include (UseJava)
......@@ -14,3 +16,10 @@ add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist)
# use listing file to specify sources and specify output directory (issue #17316)
add_jar(hello3 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/hello3")
add_test (NAME Java.Jar
COMMAND "${Java_JAVA_EXECUTABLE}" -classpath hello.jar HelloWorld)
add_test (NAME Java.JarSourceList
COMMAND "${Java_JAVA_EXECUTABLE}" -classpath hello2.jar HelloWorld)
add_test (NAME Java.JarSourceListAndOutput
COMMAND "${Java_JAVA_EXECUTABLE}" -classpath "${CMAKE_CURRENT_BINARY_DIR}/hello3/hello3.jar" HelloWorld)
......@@ -3,6 +3,8 @@ project(helloJavah Java CXX)
cmake_minimum_required (VERSION 2.6)
set(CMAKE_VERBOSE_MAKEFILE 1)
include(CTest)
find_package(Java COMPONENTS Development)
include (UseJava)
......@@ -21,3 +23,6 @@ add_dependencies(B B_javah)
target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
${JAVA_INCLUDE_PATH}
${JAVA_INCLUDE_PATH2})
add_test (NAME Java.Javah
COMMAND "${Java_JAVA_EXECUTABLE}" -Djava.library.path=$<TARGET_FILE_DIR:B> -classpath hello3.jar HelloWorld2)
......@@ -3,6 +3,8 @@ project(helloJavaNativeHeaders Java CXX)
cmake_minimum_required (VERSION 2.6)
set(CMAKE_VERBOSE_MAKEFILE 1)
include (CTest)
find_package(Java COMPONENTS Development)
include (UseJava)
......@@ -16,3 +18,7 @@ add_jar(hello4 HelloWorld3.java)
add_library(D SHARED D.cpp E.cpp)
target_link_libraries (D PRIVATE D1-native E1-native)
add_test (NAME Java.NativeHeaders
COMMAND "${Java_JAVA_EXECUTABLE}" -Djava.library.path=$<TARGET_FILE_DIR:D> -classpath hello4.jar HelloWorld3)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment