bump product version to 4.1.6.2
[LibreOffice.git] / solenv / gbuild / JunitTest.mk
blob6b86f6e7f3f66616265e0c9baf46789b79c54a3e
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 .
21 # JunitTest class
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,\
29 rm -f $@ $@.log)
31 ifneq (,$(strip $(OOO_JUNIT_JAR)))
33 # DBGSV_ERROR_OUT => in non-product builds, ensure that tools-based assertions do not pop up as message box, but are routed to the shell
34 # DISABLE_SAL_DBGBOX is the same, for osl/diagnose.h on Windows only
35 .PHONY : $(call gb_JunitTest_get_target,%)
36 $(call gb_JunitTest_get_target,%) :
37 $(call gb_Output_announce,$*,$(true),JUT,2)
38 $(call gb_Helper_abbreviate_dirs,\
39 rm -rf $(call gb_JunitTest_get_userdir,$*) && \
40 mkdir -p $(call gb_JunitTest_get_userdir,$*) && \
41 (DBGSV_ERROR_OUT=shell DISABLE_SAL_DBGBOX=t \
42 $(gb_JunitTest_JAVACOMMAND) \
43 -classpath "$(T_CP)" \
44 $(DEFS) \
45 org.junit.runner.JUnitCore \
46 $(CLASSES) > $@.log 2>&1 || \
47 (cat $@.log \
48 && echo "to rerun just this failed test without all others, run:" \
49 && echo && echo " make JunitTest_$*" && echo \
50 && echo "cd into the module dir to run the tests faster" \
51 && echo "Or to do interactive debugging (non-Windows), run two shells with:" \
52 && echo \
53 && echo " make debugrun" \
54 && echo " make gb_JunitTest_DEBUGRUN=T JunitTest_$*" \
55 && echo \
56 && false)))
57 $(CLEAN_CMD)
59 define gb_JunitTest_JunitTest
60 $(call gb_JunitTest_get_target,$(1)) : T_CP := $(call gb_JavaClassSet_get_classdir,$(call gb_JunitTest_get_classsetname,$(1)))$$(gb_CLASSPATHSEP)$(OOO_JUNIT_JAR)$$(gb_CLASSPATHSEP)$(OUTDIR)/lib
61 $(call gb_JunitTest_get_target,$(1)) : CLASSES :=
62 $(eval $(call gb_JunitTest_JunitTest_platform,$(1)))
64 $(call gb_JavaClassSet_JavaClassSet,$(call gb_JunitTest_get_classsetname,$(1)))
65 $(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(OOO_JUNIT_JAR))
66 $(call gb_JunitTest_get_target,$(1)) : $(call gb_JavaClassSet_get_target,$(call gb_JunitTest_get_classsetname,$(1)))
67 $(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
68 $(call gb_Helper_make_userfriendly_targets,$(1),JunitTest)
70 endef
72 define gb_JunitTest_set_defs
73 $(call gb_JunitTest_get_target,$(1)) : DEFS := $(2)
75 endef
77 define gb_JunitTest_add_classes
78 $(call gb_JunitTest_get_target,$(1)) : CLASSES += $(2)
80 endef
82 define gb_JunitTest_add_class
83 $(call gb_JunitTest_add_classes,$(1),$(2))
85 endef
88 define gb_JunitTest_add_sourcefile
89 $(call gb_JavaClassSet_add_sourcefile,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
91 endef
93 define gb_JunitTest_add_sourcefiles
94 $(foreach sourcefile,$(2),$(call gb_JunitTest_add_sourcefile,$(1),$(sourcefile)))
96 endef
98 define gb_JunitTest_add_jar
99 $$(call gb_Output_error,\
100 gb_JunitTest_add_jar: use gb_JunitTest_use_jar instead.)
101 endef
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_outdir_target,$(2))
106 $(call gb_JunitTest_get_target,$(1)) : $(call gb_Jar_get_outdir_target,$(2))
108 endef
110 define gb_JunitTest_add_jars
111 $$(call gb_Output_error,\
112 gb_JunitTest_add_jars: use gb_JunitTest_use_jars instead.)
113 endef
115 define gb_JunitTest_use_jars
116 $(foreach jar,$(2),$(call gb_JunitTest_use_jar,$(1),$(jar)))
118 endef
120 define gb_JunitTest_add_jar_classset
121 $$(call gb_Output_error,\
122 gb_JunitTest_add_jar_classset: use gb_JunitTest_use_jar_classset instead.)
123 endef
125 # see gb_JavaClassSet_use_jar_classset
126 define gb_JunitTest_use_jar_classset
127 $(call gb_JavaClassSet_use_jar_classset,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
128 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(2)))
130 endef
132 define gb_JunitTest_use_system_jar
133 $(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
135 endef
137 define gb_JunitTest_use_system_jars
138 $(foreach jar,$(2),$(call gb_JunitTest_use_system_jar,$(1),$(jar)))
140 endef
142 # this forwards to functions that must be defined in RepositoryExternal.mk.
143 # $(eval $(call gb_JunitTest_use_external,jar,external))
144 define gb_JunitTest_use_external
145 $(if $(value gb_JunitTest__use_$(2)),\
146 $(call gb_JunitTest__use_$(2),$(1)),\
147 $(error gb_JunitTest_use_external: unknown external: $(2)))
149 endef
151 define gb_JunitTest_use_externals
152 $(foreach external,$(2),$(call gb_JunitTest_use_external,$(1),$(external)))
154 endef
156 define gb_JunitTest_add_customtarget_dependency
157 $$(call gb_Output_error,\
158 gb_JunitTest_add_customtarget_dependency: use gb_Jar_use_customtarget instead.)
159 endef
161 define gb_JunitTest_use_customtarget
162 $(call gb_JavaClassSet_use_customtarget,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
163 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_CustomTarget_get_workdir,$(2))
165 endef
167 define gb_JunitTest_add_customtarget_dependencies
168 $$(call gb_Output_error,\
169 gb_JunitTest_add_customtarget_dependencies: use gb_Jar_use_customtargets instead.)
170 endef
172 define gb_JunitTest_use_customtargets
173 $(foreach dependency,$(2),$(call gb_JunitTest_use_customtarget,$(1),$(dependency)))
175 endef
177 else # OOO_JUNIT_JAR
179 .PHONY : $(call gb_JunitTest_get_target,$(1))
180 $(call gb_JunitTest_get_target,%) :
181 $(call gb_Output_announce,$* (skipped - no Junit),$(true),JUT,2)
182 @true
184 define gb_JunitTest_JunitTest
185 $(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
186 $(call gb_Helper_make_userfriendly_targets,$(1),JunitTest)
188 endef
190 gb_JunitTest_set_defs :=
191 gb_JunitTest_add_classes :=
192 gb_JunitTest_add_class :=
193 gb_JunitTest_add_sourcefile :=
194 gb_JunitTest_add_sourcefiles :=
195 gb_JunitTest_use_jar :=
196 gb_JunitTest_use_jars :=
197 gb_JunitTest_use_jar_classset :=
198 gb_JunitTest_use_system_jar :=
199 gb_JunitTest_use_system_jars :=
200 gb_JunitTest_use_external :=
201 gb_JunitTest_use_externals :=
202 gb_JunitTest_use_customtarget :=
203 gb_JunitTest_use_customtargets :=
205 endif # OOO_JUNIT_JAR
206 # vim: set noet sw=4: