xref: /aoo4110/main/solenv/gbuild/JunitTest.mk (revision b1cdbd2c)
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
49$(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
50$(call gb_JunitTest_get_target,$(1)) : CLASSES :=
51$(call gb_JunitTest_JunitTest_platform,$(1))
52
53$(call gb_JavaClassSet_JavaClassSet,$(call gb_JunitTest_get_classsetname,$(1)))
54$(call gb_JunitTest_get_target,$(1)) : $(call gb_JavaClassSet_get_target,$(call gb_JunitTest_get_classsetname,$(1)))
55$(eval $(call gb_Module_register_target,$(call gb_JunitTest_get_target,$(1)),$(call gb_JunitTest_get_clean_target,$(1))))
56endef
57
58define gb_JunitTest_set_defs
59$(call gb_JunitTest_get_target,$(1)) : DEFS := $(2)
60
61endef
62
63define gb_JunitTest_add_classes
64$(call gb_JunitTest_get_target,$(1)) : CLASSES += $(2)
65
66endef
67
68define gb_JunitTest_add_class
69$(call gb_JunitTest_add_classes,$(1),$(2))
70
71endef
72
73
74define gb_JunitTest_add_sourcefile
75$(call gb_JavaClassSet_add_sourcefile,$(call gb_JunitTest_get_classsetname,$(1)),$(2))
76
77endef
78
79define gb_JunitTest_add_sourcefiles
80$(foreach sourcefile,$(2),$(call gb_JunitTest_add_sourcefile,$(1),$(sourcefile)))
81
82endef
83
84define gb_JunitTest_set_classpath
85$(call gb_JunitTest_get_target,$(1)) : CLASSPATH := $(2)
86
87endef
88
89define gb_JunitTest_add_jar
90$(call gb_JunitTest_get_target,$(1)) : CLASSPATH := $$(CLASSPATH)$(gb_CLASSPATHSEP)$(2)
91$(call gb_JunitTest_get_target,$(1)) : $(2)
92
93endef
94
95define gb_JunitTest_add_jars
96$(foreach jar,$(2),$(call gb_JunitTest_add_jar,$(1),$(jar)))
97
98endef
99# vim: set noet sw=4 ts=4:
100