Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / solenv / gbuild / JunitTest.mk
blob36f29b50ef2830a5d1ad5d144014c580022dd8b0
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 .PHONY : $(call gb_JunitTest_get_target,%)
34 $(call gb_JunitTest_get_target,%) :
35 ifneq ($(gb_SUPPRESS_TESTS),)
36 @true
37 else
38 $(call gb_Output_announce,$*,$(true),JUT,2)
39 $(call gb_Helper_abbreviate_dirs,\
40 rm -rf $(call gb_JunitTest_get_userdir,$*) && \
41 mkdir -p $(call gb_JunitTest_get_userdir,$*)/user && \
42 cp $(SRCDIR)/qadevOOo/qa/registrymodifications.xcu $(call gb_JunitTest_get_userdir,$*)/user/ && \
43 ($(gb_JunitTest_JAVACOMMAND) \
44 -classpath "$(T_CP)" \
45 $(DEFS) \
46 org.junit.runner.JUnitCore \
47 $(CLASSES) > $@.log 2>&1 || \
48 (cat $@.log \
49 && echo "to rerun just this failed test without all others, run:" \
50 && echo && echo " make JunitTest_$*" && echo \
51 && echo "cd into the module dir to run the tests faster" \
52 && echo "Or to do interactive debugging, run two shells with:" \
53 && echo \
54 && echo " make debugrun" \
55 && echo " make gb_JunitTest_DEBUGRUN=T JunitTest_$*" \
56 && echo \
57 && false)))
58 $(CLEAN_CMD)
59 endif
61 define gb_JunitTest_JunitTest
62 $(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)
63 $(call gb_JunitTest_get_target,$(1)) : CLASSES :=
64 $(eval $(call gb_JunitTest_JunitTest_platform,$(1)))
66 $(call gb_JavaClassSet_JavaClassSet,$(call gb_JunitTest_get_classsetname,$(1)))
67 $(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(OOO_JUNIT_JAR))
68 $(if $(HAMCREST_JAR),$(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(HAMCREST_JAR)))
69 $(call gb_JunitTest_get_target,$(1)) : $(call gb_JavaClassSet_get_target,$(call gb_JunitTest_get_classsetname,$(1)))
70 $(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
71 $(call gb_Helper_make_userfriendly_targets,$(1),JunitTest)
73 endef
75 define gb_JunitTest_set_defs
76 $(call gb_JunitTest_get_target,$(1)) : DEFS := $(2)
78 endef
80 define gb_JunitTest_add_classes
81 $(call gb_JunitTest_get_target,$(1)) : CLASSES += $(2)
83 endef
85 define gb_JunitTest_add_class
86 $(call gb_JunitTest_add_classes,$(1),$(2))
88 endef
91 define gb_JunitTest_add_sourcefile
92 $(call gb_JavaClassSet_add_sourcefile,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
94 endef
96 define gb_JunitTest_add_sourcefiles
97 $(foreach sourcefile,$(2),$(call gb_JunitTest_add_sourcefile,$(1),$(sourcefile)))
99 endef
101 define gb_JunitTest_use_jar
102 $(call gb_JavaClassSet_use_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
103 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_Jar_get_target,$(2))
104 $(call gb_JunitTest_get_target,$(1)) : $(call gb_Jar_get_target,$(2))
106 endef
108 define gb_JunitTest_use_jars
109 $(foreach jar,$(2),$(call gb_JunitTest_use_jar,$(1),$(jar)))
111 endef
113 # see gb_JavaClassSet_use_jar_classset
114 define gb_JunitTest_use_jar_classset
115 $(call gb_JavaClassSet_use_jar_classset,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
116 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(2)))
118 endef
120 define gb_JunitTest_use_system_jar
121 $(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
123 endef
125 define gb_JunitTest_use_system_jars
126 $(foreach jar,$(2),$(call gb_JunitTest_use_system_jar,$(1),$(jar)))
128 endef
130 # this forwards to functions that must be defined in RepositoryExternal.mk.
131 # $(eval $(call gb_JunitTest_use_external,jar,external))
132 define gb_JunitTest_use_external
133 $(if $(value gb_JunitTest__use_$(2)),\
134 $(call gb_JunitTest__use_$(2),$(1)),\
135 $(error gb_JunitTest_use_external: unknown external: $(2)))
137 endef
139 define gb_JunitTest_use_externals
140 $(foreach external,$(2),$(call gb_JunitTest_use_external,$(1),$(external)))
142 endef
144 define gb_JunitTest_use_customtarget
145 $(call gb_JavaClassSet_use_customtarget,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
146 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_CustomTarget_get_workdir,$(2))
148 endef
150 define gb_JunitTest_use_customtargets
151 $(foreach dependency,$(2),$(call gb_JunitTest_use_customtarget,$(1),$(dependency)))
153 endef
155 else # OOO_JUNIT_JAR
157 .PHONY : $(call gb_JunitTest_get_target,$(1))
158 $(call gb_JunitTest_get_target,%) :
159 ifeq ($(gb_SUPPRESS_TESTS),)
160 $(call gb_Output_announce,$* (skipped - no Junit),$(true),JUT,2)
161 endif
162 @true
164 define gb_JunitTest_JunitTest
165 $(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
166 $(call gb_Helper_make_userfriendly_targets,$(1),JunitTest)
168 endef
170 gb_JunitTest_set_defs :=
171 gb_JunitTest_add_classes :=
172 gb_JunitTest_add_class :=
173 gb_JunitTest_add_sourcefile :=
174 gb_JunitTest_add_sourcefiles :=
175 gb_JunitTest_use_jar :=
176 gb_JunitTest_use_jars :=
177 gb_JunitTest_use_jar_classset :=
178 gb_JunitTest_use_system_jar :=
179 gb_JunitTest_use_system_jars :=
180 gb_JunitTest_use_external :=
181 gb_JunitTest_use_externals :=
182 gb_JunitTest_use_customtarget :=
183 gb_JunitTest_use_customtargets :=
185 endif # OOO_JUNIT_JAR
186 # vim: set noet sw=4: