xref: /aoo41x/main/solenv/gbuild/JunitTest.mk (revision cdf0e10c)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2011 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28
29# JunitTest class
30
31gb_JunitTest_JAVACOMMAND := $(JAVAINTERPRETER) $(JAVAIFLAGS)
32
33# in non-product builds, ensure that tools-based assertions do not pop up as message box, but are routed to the shell
34DBGSV_ERROR_OUT := shell
35export DBGSV_ERROR_OUT
36
37.PHONY : $(call gb_JunitTest_get_clean_target,%)
38$(call gb_JunitTest_get_clean_target,%) : $(call gb_JavaClassSet_get_clean_target,$(call gb_JunitTest_get_classsetname,%))
39	$(call gb_Helper_abbreviate_dirs,\
40		rm -f $@ $@.log)
41
42.PHONY : $(call gb_JunitTest_get_target,$(1))
43$(call gb_JunitTest_get_target,%) :
44	$(call gb_Output_announce,$*,$(true),JUT,2)
45	$(call gb_Helper_abbreviate_dirs_native,\
46        rm -rf $(call gb_JunitTest_get_userdir,$*) && \
47		mkdir -p $(call gb_JunitTest_get_userdir,$*) && \
48		$(gb_JunitTest_JAVACOMMAND) -cp "$(CLASSPATH)" $(DEFS) org.junit.runner.JUnitCore $(CLASSES) 2>&1 > $@.log || (cat $@.log && false) && \
49        rm -rf $(call gb_JunitTest_get_userdir,$*))
50	$(CLEAN_CMD)
51
52define gb_JunitTest_JunitTest
53$(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
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)))
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