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 ($(gb_TEST_ENV_VARS
) $(ICECREAM_RUN
) $(gb_JunitTest_JAVACOMMAND
) \
45 -classpath
"$(T_CP)" \
47 org.junit.runner.JUnitCore \
48 $(CLASSES
) > $@.log
2>&1 || \
50 && echo
"to rerun just this failed test without all others, run:" \
51 && echo
&& echo
" make JunitTest_$*" && echo \
52 && echo
"cd into the module dir to run the tests faster" \
53 && echo
"Or to do interactive debugging, run two shells with:" \
55 && echo
" make debugrun" \
56 && echo
" make gb_JunitTest_DEBUGRUN=T JunitTest_$*" \
60 $(call gb_Trace_EndRange
,$*,JUT
)
63 define gb_JunitTest_JunitTest
64 $(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
)
65 $(call gb_JunitTest_get_target
,$(1)) : CLASSES
:=
66 $(eval
$(call gb_JunitTest_JunitTest_platform
,$(1)))
68 $(call gb_JavaClassSet_JavaClassSet
,$(call gb_JunitTest_get_classsetname
,$(1)))
69 $(call gb_JavaClassSet_use_system_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(OOO_JUNIT_JAR
))
70 $(if
$(HAMCREST_JAR
),$(call gb_JavaClassSet_use_system_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(HAMCREST_JAR
)))
71 $(call gb_JunitTest_get_target
,$(1)) : $(call gb_JavaClassSet_get_target
,$(call gb_JunitTest_get_classsetname
,$(1)))
72 $(eval
$(call gb_Module_register_target
,$(call gb_JunitTest_get_target
,$(1)),$(call gb_JunitTest_get_clean_target
,$(1))))
73 $(call gb_Helper_make_userfriendly_targets
,$(1),JunitTest
)
77 define gb_JunitTest_set_defs
78 $(call gb_JunitTest_get_target
,$(1)) : DEFS
:= $(2)
82 define gb_JunitTest_add_classes
83 $(call gb_JunitTest_get_target
,$(1)) : CLASSES
+= $(2)
87 define gb_JunitTest_add_class
88 $(call gb_JunitTest_add_classes
,$(1),$(2))
93 define gb_JunitTest_add_sourcefile
94 $(call gb_JavaClassSet_add_sourcefile
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
98 define gb_JunitTest_add_sourcefiles
99 $(foreach sourcefile
,$(2),$(call gb_JunitTest_add_sourcefile
,$(1),$(sourcefile
)))
103 define gb_JunitTest_use_jar
104 $(call gb_JavaClassSet_use_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
105 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(call gb_Jar_get_target
,$(2))
106 $(call gb_JunitTest_get_target
,$(1)) : $(call gb_Jar_get_target
,$(2))
110 define gb_JunitTest_use_jars
111 $(foreach jar
,$(2),$(call gb_JunitTest_use_jar
,$(1),$(jar
)))
115 # see gb_JavaClassSet_use_jar_classset
116 define gb_JunitTest_use_jar_classset
117 $(call gb_JavaClassSet_use_jar_classset
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
118 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(call gb_JavaClassSet_get_classdir
,$(call gb_Jar_get_classsetname
,$(2)))
122 define gb_JunitTest_add_classpath
123 $(call gb_JavaClassSet_add_classpath
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
124 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(2)
128 define gb_JunitTest_use_system_jar
129 $(call gb_JavaClassSet_use_system_jar
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
133 define gb_JunitTest_use_system_jars
134 $(foreach jar
,$(2),$(call gb_JunitTest_use_system_jar
,$(1),$(jar
)))
138 # this forwards to functions that must be defined in RepositoryExternal.mk.
139 # $(eval $(call gb_JunitTest_use_external,jar,external))
140 define gb_JunitTest_use_external
141 $(if
$(value gb_JunitTest__use_
$(2)),\
142 $(call gb_JunitTest__use_
$(2),$(1)),\
143 $(error gb_JunitTest_use_external
: unknown external
: $(2)))
147 define gb_JunitTest_use_externals
148 $(foreach external
,$(2),$(call gb_JunitTest_use_external
,$(1),$(external
)))
152 define gb_JunitTest_use_customtarget
153 $(call gb_JavaClassSet_use_customtarget
,$(call gb_JunitTest_get_classsetname
,$(1)),$(2))
154 $(call gb_JunitTest_get_target
,$(1)) : T_CP
:= $$(T_CP
)$$(gb_CLASSPATHSEP
)$(call gb_CustomTarget_get_workdir
,$(2))
158 define gb_JunitTest_use_customtargets
159 $(foreach dependency
,$(2),$(call gb_JunitTest_use_customtarget
,$(1),$(dependency
)))
163 define gb_JunitTest_use_unoapi_jars
164 $(eval
$(call gb_JunitTest_use_jars
,$(1),\
172 define gb_JunitTest_use_unoapi_test_class
173 $(eval
$(call gb_JunitTest_add_classes
,$(1),\
174 org.openoffice.
test.UnoApiTest \
179 # To be used by gb_JunitTest_set_unoapi_test_defaults
180 # <module>_unoapi_1 => <module>_1 => <module> => <module>/qa/unoapi
181 gb_JunitTest__unoapi_iter
= $(subst _unoapi
,,$(1))
182 gb_JunitTest__unoapi_module
= $(firstword $(subst _
, ,$(gb_JunitTest__unoapi_iter
)))
183 gb_JunitTest__unoapi_dir
= $(if
$(2),$(2),$(gb_JunitTest__unoapi_module
)/qa
/unoapi
)
185 # $(1) = test name (prefer <module>_unoapi for defaults, example <module>_unoapi_1)
186 # $(2) = test directory base (def: <module>_unoapi_1 => <module>_1/qa/unoapi)
187 # $(3) = SCE file (def: <module>_1.sce)
188 # $(4) = XCL file (def: knownissues.xcl)
189 # $(5) = test document directory (def: testdocuments; use . for base)
190 define gb_JunitTest_set_unoapi_test_defaults
191 $(eval
$(call gb_JunitTest_set_defs
,$(1),\
193 -Dorg.openoffice.
test.arg.sce
=$(SRCDIR
)/$(gb_JunitTest__unoapi_dir
)/$(if
$(3),$(3),$(gb_JunitTest__unoapi_iter
).sce
) \
194 -Dorg.openoffice.
test.arg.xcl
=$(SRCDIR
)/$(gb_JunitTest__unoapi_dir
)/$(if
$(4),$(4),knownissues.xcl
) \
195 -Dorg.openoffice.
test.arg.tdoc
=$(SRCDIR
)/$(gb_JunitTest__unoapi_dir
)/$(if
$(5),$(5),testdocuments
) \
198 $(eval
$(call gb_JunitTest_use_unoapi_jars
,$(1)))
199 $(eval
$(call gb_JunitTest_use_unoapi_test_class
,$(1)))
205 .PHONY
: $(call gb_JunitTest_get_target
,$(1))
206 $(call gb_JunitTest_get_target
,%) :
207 ifeq ($(gb_SUPPRESS_TESTS
),)
208 $(call gb_Output_announce
,$* (skipped
- no Junit
),$(true
),JUT
,2)
212 define gb_JunitTest_JunitTest
213 $(eval
$(call gb_Module_register_target
,$(call gb_JunitTest_get_target
,$(1)),$(call gb_JunitTest_get_clean_target
,$(1))))
214 $(call gb_Helper_make_userfriendly_targets
,$(1),JunitTest
)
218 gb_JunitTest_set_defs
:=
219 gb_JunitTest_add_classes
:=
220 gb_JunitTest_add_class
:=
221 gb_JunitTest_add_sourcefile
:=
222 gb_JunitTest_add_sourcefiles
:=
223 gb_JunitTest_use_jar
:=
224 gb_JunitTest_use_jars
:=
225 gb_JunitTest_use_jar_classset
:=
226 gb_JunitTest_use_system_jar
:=
227 gb_JunitTest_use_system_jars
:=
228 gb_JunitTest_use_external
:=
229 gb_JunitTest_use_externals
:=
230 gb_JunitTest_use_customtarget
:=
231 gb_JunitTest_use_customtargets
:=
233 endif # OOO_JUNIT_JAR
234 # vim: set noet sw=4: