blob: 84faa6874998764eb9e05c696977a3f6385886e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#
# This file provides functions for JUnit support.
#
# Available Functions:
#
# add_junit_test(<target name>
# CLASSPATH [path1 ...]
# TESTS [class1 ...]
# )
#
# This command creates a target for executing JUnit test classes
# using the specified class path.
#
find_file(JUNIT_JAR
NAMES
junit4.jar
PATHS
${JAVA_LIB_INSTALL_DIR}
/usr/share/java
)
function(add_junit_test TARGET_NAME)
if (WIN32 AND NOT CYGWIN)
set(SEPARATOR ";")
else (WIN32 AND NOT CYGWIN)
set(SEPARATOR ":")
endif(WIN32 AND NOT CYGWIN)
set(REPORTS_DIR "reports")
foreach (ARG ${ARGN})
if (ARG MATCHES "(CLASSPATH|TESTS|REPORTS_DIR)")
set(TYPE ${ARG})
else (ARG MATCHES "(CLASSPATH|TESTS|REPORTS_DIR)")
if (TYPE MATCHES "CLASSPATH")
set(CLASSPATH "${CLASSPATH}${SEPARATOR}${ARG}")
elseif (TYPE MATCHES "TESTS")
set(TESTS ${TESTS} ${ARG})
elseif (TYPE MATCHES "REPORTS_DIR")
set(REPORTS_DIR ${ARG})
endif(TYPE MATCHES "CLASSPATH")
endif(ARG MATCHES "(CLASSPATH|TESTS|REPORTS_DIR)")
endforeach(ARG)
add_custom_target(${TARGET_NAME}
COMMAND
mkdir -p "${REPORTS_DIR}"
COMMAND
${CMAKE_Java_RUNTIME}
-Djunit.reports.dir=${REPORTS_DIR}
-classpath ${CLASSPATH}
com.netscape.test.TestRunner
${TESTS}
)
endfunction(add_junit_test)
|