1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 gb_JunitTest_JAVACOMMAND
:= $(JAVAINTERPRETER
) $(JAVAIFLAGS
)
26 .PHONY
: $(call gb_JunitTest_get_clean_target
,%)
27 $(call gb_JunitTest_get_clean_target
,%) : $(call gb_JavaClassSet_get_clean_target
,$(call gb_JunitTest_get_classsetname
,%))
28 $(call gb_Helper_abbreviate_dirs
,\
31 ifneq (,$(strip $(OOO_JUNIT_JAR
)))
33 .PHONY
: $(call gb_JunitTest_get_target
,%)
34 $(call gb_JunitTest_get_target
,%) :
35 ifneq ($(gb_SUPPRESS_TESTS
),)
38 $(call gb_Output_announce
,$*,$(true
),JUT
,2)
39 $(call gb_Trace_StartRange
,$*,JUT
)
40 $(call gb_Helper_abbreviate_dirs
,\
41 rm -rf
$(call gb_JunitTest_get_userdir
,$*) && \
42 mkdir
-p
$(call gb_JunitTest_get_userdir
,$*)/user
&& \
43 cp
$(SRCDIR
)/qadevOOo
/qa
/registrymodifications.xcu
$(call gb_JunitTest_get_userdir
,$*)/user
/ && \
44 $(call gb_CppunitTest_coredumpctl_setup
,$@
) \
45 ($(gb_TEST_ENV_VARS
) $(ICECREAM_RUN
) $(gb_CppunitTest_coredumpctl_run
) \
46 $(gb_JunitTest_JAVACOMMAND
) \
47 -classpath
"$(T_CP)" \
49 org.junit.runner.JUnitCore \
50 $(CLASSES
) > $@.log
2>&1 || \
52 && echo
"to rerun just this failed test without all others, run:" \
53 && echo
&& echo
" make JunitTest_$*" && echo \
54 && echo
"cd into the module dir to run the tests faster" \
55 && echo
"Or to do interactive debugging, run two shells with:" \
57 && echo
" make debugrun" \
58 && echo
" make gb_JunitTest_DEBUGRUN=T JunitTest_$*" \
62 $(call gb_Trace_EndRange
,$*,JUT
)
65 define gb_JunitTest_JunitTest
66 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $(call gb_JavaClassSet_get_classdir
,$(call gb_JunitTest_get_classsetname
,$(1)))$$(gb_CLASSPATHSEP
)$(OOO_JUNIT_JAR
)$(if
$(HAMCREST_JAR
),$$(gb_CLASSPATHSEP
)$(HAMCREST_JAR
))$$(gb_CLASSPATHSEP
)$(INSTROOT
)/$(LIBO_URE_LIB_FOLDER
)
67 $(call gb_JunitTest_get_target
,$(1)) : CLASSES
:=
68 $(eval
$(call gb_JunitTest_JunitTest_platform
,$(1)))
70 $(call gb_JavaClassSet_JavaClassSet
,$(call gb_JunitTest_get_classsetname
,$(1)))
71 $(call gb_JavaClassSet_use_system_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(OOO_JUNIT_JAR
))
72 $(if
$(HAMCREST_JAR
),$(call gb_JavaClassSet_use_system_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(HAMCREST_JAR
)))
73 $(call gb_JunitTest_get_target
,$(1)) : $(call gb_JavaClassSet_get_target
,$(call gb_JunitTest_get_classsetname
,$(1)))
74 $(eval
$(call gb_Module_register_target
,$(call gb_JunitTest_get_target
,$(1)),$(call gb_JunitTest_get_clean_target
,$(1))))
75 $(call gb_Helper_make_userfriendly_targets
,$(1),JunitTest
)
79 define gb_JunitTest_set_defs
80 $(call gb_JunitTest_get_target
,$(1)) : DEFS
:= $(2)
84 define gb_JunitTest_add_classes
85 $(call gb_JunitTest_get_target
,$(1)) : CLASSES
+= $(2)
89 define gb_JunitTest_add_class
90 $(call gb_JunitTest_add_classes
,$(1),$(2))
95 define gb_JunitTest_add_sourcefile
96 $(call gb_JavaClassSet_add_sourcefile
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
100 define gb_JunitTest_add_sourcefiles
101 $(foreach sourcefile
,$(2),$(call gb_JunitTest_add_sourcefile
,$(1),$(sourcefile
)))
105 define gb_JunitTest_use_jar
106 $(call gb_JavaClassSet_use_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
107 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(call gb_Jar_get_target
,$(2))
108 $(call gb_JunitTest_get_target
,$(1)) : $(call gb_Jar_get_target
,$(2))
112 define gb_JunitTest_use_jars
113 $(foreach jar
,$(2),$(call gb_JunitTest_use_jar
,$(1),$(jar
)))
117 # see gb_JavaClassSet_use_jar_classset
118 define gb_JunitTest_use_jar_classset
119 $(call gb_JavaClassSet_use_jar_classset
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
120 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(call gb_JavaClassSet_get_classdir
,$(call gb_Jar_get_classsetname
,$(2)))
124 define gb_JunitTest_add_classpath
125 $(call gb_JavaClassSet_add_classpath
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
126 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(2)
130 define gb_JunitTest_use_system_jar
131 $(call gb_JavaClassSet_use_system_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
135 define gb_JunitTest_use_system_jars
136 $(foreach jar
,$(2),$(call gb_JunitTest_use_system_jar
,$(1),$(jar
)))
140 # this forwards to functions that must be defined in RepositoryExternal.mk.
141 # $(eval $(call gb_JunitTest_use_external,jar,external))
142 define gb_JunitTest_use_external
143 $(if
$(value gb_JunitTest__use_
$(2)),\
144 $(call gb_JunitTest__use_
$(2),$(1)),\
145 $(error gb_JunitTest_use_external
: unknown external
: $(2)))
149 define gb_JunitTest_use_externals
150 $(foreach external
,$(2),$(call gb_JunitTest_use_external
,$(1),$(external
)))
154 define gb_JunitTest_use_customtarget
155 $(call gb_JavaClassSet_use_customtarget
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
156 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(call gb_CustomTarget_get_workdir
,$(2))
160 define gb_JunitTest_use_customtargets
161 $(foreach dependency
,$(2),$(call gb_JunitTest_use_customtarget
,$(1),$(dependency
)))
165 define gb_JunitTest_use_unoapi_jars
166 $(eval
$(call gb_JunitTest_use_jars
,$(1),\
174 define gb_JunitTest_use_unoapi_test_class
175 $(eval
$(call gb_JunitTest_add_classes
,$(1),\
176 org.openoffice.
test.UnoApiTest \
181 # To be used by gb_JunitTest_set_unoapi_test_defaults
182 # <module>_unoapi_1 => <module>_1 => <module> => <module>/qa/unoapi
183 gb_JunitTest__unoapi_iter
= $(subst _unoapi
,,$(1))
184 gb_JunitTest__unoapi_module
= $(firstword $(subst _
, ,$(gb_JunitTest__unoapi_iter
)))
185 gb_JunitTest__unoapi_dir
= $(if
$(2),$(2),$(gb_JunitTest__unoapi_module
)/qa
/unoapi
)
187 # $(1) = test name (prefer <module>_unoapi for defaults, example <module>_unoapi_1)
188 # $(2) = test directory base (def: <module>_unoapi_1 => <module>_1/qa/unoapi)
189 # $(3) = SCE file (def: <module>_1.sce)
190 # $(4) = XCL file (def: knownissues.xcl)
191 # $(5) = test document directory (def: testdocuments; use . for base)
192 define gb_JunitTest_set_unoapi_test_defaults
193 $(eval
$(call gb_JunitTest_set_defs
,$(1),\
195 -Dorg.openoffice.
test.arg.sce
=$(SRCDIR
)/$(gb_JunitTest__unoapi_dir
)/$(if
$(3),$(3),$(gb_JunitTest__unoapi_iter
).sce
) \
196 -Dorg.openoffice.
test.arg.xcl
=$(SRCDIR
)/$(gb_JunitTest__unoapi_dir
)/$(if
$(4),$(4),knownissues.xcl
) \
197 -Dorg.openoffice.
test.arg.tdoc
=$(SRCDIR
)/$(gb_JunitTest__unoapi_dir
)/$(if
$(5),$(5),testdocuments
) \
200 $(eval
$(call gb_JunitTest_use_unoapi_jars
,$(1)))
201 $(eval
$(call gb_JunitTest_use_unoapi_test_class
,$(1)))
207 .PHONY
: $(call gb_JunitTest_get_target
,$(1))
208 $(call gb_JunitTest_get_target
,%) :
209 ifeq ($(gb_SUPPRESS_TESTS
),)
210 $(call gb_Output_announce
,$* (skipped
- no Junit
),$(true
),JUT
,2)
214 define gb_JunitTest_JunitTest
215 $(eval
$(call gb_Module_register_target
,$(call gb_JunitTest_get_target
,$(1)),$(call gb_JunitTest_get_clean_target
,$(1))))
216 $(call gb_Helper_make_userfriendly_targets
,$(1),JunitTest
)
220 gb_JunitTest_set_defs
:=
221 gb_JunitTest_add_classes
:=
222 gb_JunitTest_add_class
:=
223 gb_JunitTest_add_sourcefile
:=
224 gb_JunitTest_add_sourcefiles
:=
225 gb_JunitTest_use_jar
:=
226 gb_JunitTest_use_jars
:=
227 gb_JunitTest_use_jar_classset
:=
228 gb_JunitTest_use_system_jar
:=
229 gb_JunitTest_use_system_jars
:=
230 gb_JunitTest_use_external
:=
231 gb_JunitTest_use_externals
:=
232 gb_JunitTest_use_customtarget
:=
233 gb_JunitTest_use_customtargets
:=
235 endif # OOO_JUNIT_JAR
236 # vim: set noet sw=4: