Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / JunitTest.mk
blob30e226d614677201766ee2a0f6436464c82c63b9
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 $(call gb_Output_announce,$*,$(true),JUT,2)
36 $(call gb_Helper_abbreviate_dirs,\
37 rm -rf $(call gb_JunitTest_get_userdir,$*) && \
38 mkdir -p $(call gb_JunitTest_get_userdir,$*)/user && \
39 cp $(SRCDIR)/qadevOOo/qa/registrymodifications.xcu $(call gb_JunitTest_get_userdir,$*)/user/ && \
40 ($(gb_JunitTest_JAVACOMMAND) \
41 -classpath "$(T_CP)" \
42 $(DEFS) \
43 org.junit.runner.JUnitCore \
44 $(CLASSES) > $@.log 2>&1 || \
45 (cat $@.log \
46 && echo "to rerun just this failed test without all others, run:" \
47 && echo && echo " make JunitTest_$*" && echo \
48 && echo "cd into the module dir to run the tests faster" \
49 && echo "Or to do interactive debugging, run two shells with:" \
50 && echo \
51 && echo " make debugrun" \
52 && echo " make gb_JunitTest_DEBUGRUN=T JunitTest_$*" \
53 && echo \
54 && false)))
55 $(CLEAN_CMD)
57 define gb_JunitTest_JunitTest
58 $(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)
59 $(call gb_JunitTest_get_target,$(1)) : CLASSES :=
60 $(eval $(call gb_JunitTest_JunitTest_platform,$(1)))
62 $(call gb_JavaClassSet_JavaClassSet,$(call gb_JunitTest_get_classsetname,$(1)))
63 $(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(OOO_JUNIT_JAR))
64 $(if $(HAMCREST_JAR),$(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(HAMCREST_JAR)))
65 $(call gb_JunitTest_get_target,$(1)) : $(call gb_JavaClassSet_get_target,$(call gb_JunitTest_get_classsetname,$(1)))
66 $(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
67 $(call gb_Helper_make_userfriendly_targets,$(1),JunitTest)
69 endef
71 define gb_JunitTest_set_defs
72 $(call gb_JunitTest_get_target,$(1)) : DEFS := $(2)
74 endef
76 define gb_JunitTest_add_classes
77 $(call gb_JunitTest_get_target,$(1)) : CLASSES += $(2)
79 endef
81 define gb_JunitTest_add_class
82 $(call gb_JunitTest_add_classes,$(1),$(2))
84 endef
87 define gb_JunitTest_add_sourcefile
88 $(call gb_JavaClassSet_add_sourcefile,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
90 endef
92 define gb_JunitTest_add_sourcefiles
93 $(foreach sourcefile,$(2),$(call gb_JunitTest_add_sourcefile,$(1),$(sourcefile)))
95 endef
97 define gb_JunitTest_use_jar
98 $(call gb_JavaClassSet_use_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
99 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_Jar_get_target,$(2))
100 $(call gb_JunitTest_get_target,$(1)) : $(call gb_Jar_get_target,$(2))
102 endef
104 define gb_JunitTest_use_jars
105 $(foreach jar,$(2),$(call gb_JunitTest_use_jar,$(1),$(jar)))
107 endef
109 # see gb_JavaClassSet_use_jar_classset
110 define gb_JunitTest_use_jar_classset
111 $(call gb_JavaClassSet_use_jar_classset,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
112 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(2)))
114 endef
116 define gb_JunitTest_use_system_jar
117 $(call gb_JavaClassSet_use_system_jar,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
119 endef
121 define gb_JunitTest_use_system_jars
122 $(foreach jar,$(2),$(call gb_JunitTest_use_system_jar,$(1),$(jar)))
124 endef
126 # this forwards to functions that must be defined in RepositoryExternal.mk.
127 # $(eval $(call gb_JunitTest_use_external,jar,external))
128 define gb_JunitTest_use_external
129 $(if $(value gb_JunitTest__use_$(2)),\
130 $(call gb_JunitTest__use_$(2),$(1)),\
131 $(error gb_JunitTest_use_external: unknown external: $(2)))
133 endef
135 define gb_JunitTest_use_externals
136 $(foreach external,$(2),$(call gb_JunitTest_use_external,$(1),$(external)))
138 endef
140 define gb_JunitTest_use_customtarget
141 $(call gb_JavaClassSet_use_customtarget,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
142 $(call gb_JunitTest_get_target,$(1)) : T_CP := $$(T_CP)$$(gb_CLASSPATHSEP)$(call gb_CustomTarget_get_workdir,$(2))
144 endef
146 define gb_JunitTest_use_customtargets
147 $(foreach dependency,$(2),$(call gb_JunitTest_use_customtarget,$(1),$(dependency)))
149 endef
151 else # OOO_JUNIT_JAR
153 .PHONY : $(call gb_JunitTest_get_target,$(1))
154 $(call gb_JunitTest_get_target,%) :
155 $(call gb_Output_announce,$* (skipped - no Junit),$(true),JUT,2)
156 @true
158 define gb_JunitTest_JunitTest
159 $(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
160 $(call gb_Helper_make_userfriendly_targets,$(1),JunitTest)
162 endef
164 gb_JunitTest_set_defs :=
165 gb_JunitTest_add_classes :=
166 gb_JunitTest_add_class :=
167 gb_JunitTest_add_sourcefile :=
168 gb_JunitTest_add_sourcefiles :=
169 gb_JunitTest_use_jar :=
170 gb_JunitTest_use_jars :=
171 gb_JunitTest_use_jar_classset :=
172 gb_JunitTest_use_system_jar :=
173 gb_JunitTest_use_system_jars :=
174 gb_JunitTest_use_external :=
175 gb_JunitTest_use_externals :=
176 gb_JunitTest_use_customtarget :=
177 gb_JunitTest_use_customtargets :=
179 endif # OOO_JUNIT_JAR
180 # vim: set noet sw=4: