xref: /aoo42x/main/solenv/gbuild/JunitTest.mk (revision 958f5dcf)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24
25# JunitTest class
26
27gb_JunitTest_JAVACOMMAND := $(JAVAINTERPRETER) $(JAVAIFLAGS)
28
29# in non-product builds, ensure that tools-based assertions do not pop up as message box, but are routed to the shell
30DBGSV_ERROR_OUT := shell
31export DBGSV_ERROR_OUT
32
33.PHONY : $(call gb_JunitTest_get_clean_target,%)
34$(call gb_JunitTest_get_clean_target,%) : $(call gb_JavaClassSet_get_clean_target,$(call gb_JunitTest_get_classsetname,%))
35	$(call gb_Helper_abbreviate_dirs,\
36		rm -f $@ $@.log)
37
38.PHONY : $(call gb_JunitTest_get_target,$(1))
39$(call gb_JunitTest_get_target,%) :
40	$(call gb_Output_announce,$*,$(true),JUT,2)
41	$(call gb_Helper_abbreviate_dirs_native,\
42        rm -rf $(call gb_JunitTest_get_userdir,$*) && \
43		mkdir -p $(call gb_JunitTest_get_userdir,$*) && \
44		$(gb_JunitTest_JAVACOMMAND) -cp "$(CLASSPATH)" $(DEFS) org.junit.runner.JUnitCore $(CLASSES) 2>&1 > $@.log || (cat $@.log && false) && \
45        rm -rf $(call gb_JunitTest_get_userdir,$*))
46	$(CLEAN_CMD)
47
48define gb_JunitTest_JunitTest
49ifeq ($(HAMCREST_CORE_JAR),)
50$(call gb_JunitTest_get_target,$(1)) : CLASSPATH := $(value XCLASSPATH)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(call gb_JunitTest_get_classsetname,$(1)))$(gb_CLASSPATHSEP)$(OOO_JUNIT_JAR)$(gb_CLASSPATHSEP)$(OUTDIR)/lib
51else
52$(call gb_JunitTest_get_target,$(1)) : CLASSPATH := $(value XCLASSPATH)$(gb_CLASSPATHSEP)$(call gb_JavaClassSet_get_classdir,$(call gb_JunitTest_get_classsetname,$(1)))$(gb_CLASSPATHSEP)$(OOO_JUNIT_JAR)$(gb_CLASSPATHSEP)$(HAMCREST_CORE_JAR)$(gb_CLASSPATHSEP)$(OUTDIR)/lib
53endif
54$(call gb_JunitTest_get_target,$(1)) : CLASSES :=
55$(call gb_JunitTest_JunitTest_platform,$(1))
56
57$(call gb_JavaClassSet_JavaClassSet,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
58$(call gb_JunitTest_get_target,$(1)) : $(call gb_JavaClassSet_get_target,$(call gb_JunitTest_get_classsetname,$(1)))
59$(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
60endef
61
62define gb_JunitTest_set_defs
63$(call gb_JunitTest_get_target,$(1)) : DEFS := $(2)
64
65endef
66
67define gb_JunitTest_add_classes
68$(call gb_JunitTest_get_target,$(1)) : CLASSES += $(2)
69
70endef
71
72define gb_JunitTest_add_class
73$(call gb_JunitTest_add_classes,$(1),$(2))
74
75endef
76
77
78define gb_JunitTest_add_sourcefile
79$(call gb_JavaClassSet_add_sourcefile,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
80
81endef
82
83define gb_JunitTest_add_sourcefiles
84$(foreach sourcefile,$(2),$(call gb_JunitTest_add_sourcefile,$(1),$(sourcefile)))
85
86endef
87
88define gb_JunitTest_set_classpath
89$(call gb_JunitTest_get_target,$(1)) : CLASSPATH := $(2)
90
91endef
92
93define gb_JunitTest_add_jar
94$(call gb_JunitTest_get_target,$(1)) : CLASSPATH := $$(CLASSPATH)$(gb_CLASSPATHSEP)$(2)
95$(call gb_JunitTest_get_target,$(1)) : $(2)
96
97endef
98
99define gb_JunitTest_add_jars
100$(foreach jar,$(2),$(call gb_JunitTest_add_jar,$(1),$(jar)))
101
102endef
103# vim: set noet sw=4 ts=4:
104