xref: /aoo4110/main/solenv/inc/javaunittest.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# Makefile template for directories that contain Java unit tests.
25#
26# Before including this makefile, the following variables should be set:
27# - PRJ, PRJNAME, TARGET
28# - PACKAGE
29# - JAVATESTFILES: the unit test classes;
30#     each one of the form <basename>.java;
31#     these java files must only define classes within the package corresponding
32#     to PACKAGE, the name of each defined (outer) class should end with "_Test"
33# - JAVAFILES: optional java files, corresponding class files are generated
34#     that can be used when compiling or running the tests;
35#     each one of the form <basename>.java;
36#     these java files must only define classes within the package corresponding
37#     to PACKAGE, the name of each defined (outer) class should start with
38#     "Test"
39# - IDLTESTFILES: optional idl files, corresponding class files are generated
40#     that can be used when compiling or running the tests;
41#     each one of the form <basename>.idl;
42#     these idl files must only define entities within the module corresponding
43#     to PACKAGE, the name of each defined entity should start with "Test"
44# - JARFILES: optional jar files that can be used when compiling or running the
45#     tests;
46#     each one of the form <basename>.jar
47# All generated class files are placed into <platform>/class/test/ instead of
48# <platform>/class/, so that they are not accidentally included in jar files
49# packed from <platform>/class/ subdirectories.
50
51JAVAFILES +:= $(JAVATESTFILES)
52EXTRAJARFILES += $(OOO_JUNIT_JAR)
53
54.INCLUDE: settings.mk
55
56.IF "$(XCLASSPATH)" == ""
57XCLASSPATH := $(CLASSDIR)
58.ELSE
59XCLASSPATH !:= $(XCLASSPATH)$(PATH_SEPERATOR)$(CLASSDIR)
60.ENDIF
61CLASSDIR !:= $(CLASSDIR)/test
62
63.INCLUDE: target.mk
64
65$(JAVATARGET) : $(MISC)/$(TARGET).classdir.flag
66
67$(MISC)/$(TARGET).classdir.flag:
68    - $(MKDIR) $(CLASSDIR)
69    $(TOUCH) $@
70
71.IF "$(JAVATESTFILES)" != ""
72ALLTAR : test
73.END
74
75.IF "$(SOLAR_JAVA)" == "TRUE" && "$(OOO_JUNIT_JAR)" != ""
76test .PHONY : $(JAVATARGET)
77    $(JAVAI) $(JAVAIFLAGS) $(JAVACPS) \
78        '$(OOO_JUNIT_JAR)$(PATH_SEPERATOR)$(CLASSPATH)' \
79        org.junit.runner.JUnitCore \
80        $(foreach,i,$(JAVATESTFILES) $(subst,/,. $(PACKAGE)).$(i:s/.java//))
81.ELSE
82test .PHONY :
83    echo 'test needs SOLAR_JAVA=TRUE and OOO_JUNIT_JAR'
84.END
85
86.IF "$(IDLTESTFILES)" != ""
87
88# The following dependency (to execute javac whenever javamaker has run) does
89# not work reliably, see #i28827#:
90$(JAVAFILES) $(JAVACLASSFILES): $(MISC)/$(TARGET).javamaker.flag
91
92$(MISC)/$(TARGET).javamaker.flag: $(MISC)/$(TARGET).rdb
93    $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD $< -X$(SOLARBINDIR)/types.rdb
94    $(TOUCH) $@
95
96$(MISC)/$(TARGET).rdb .ERRREMOVE: \
97        $(foreach,i,$(IDLTESTFILES) $(subst,.idl,.urd $(MISC)/$(TARGET)/$i))
98    - rm $@
99    $(REGMERGE) $@ /UCR $<
100
101$(foreach,i,$(IDLTESTFILES) $(subst,.idl,.urd $(MISC)/$(TARGET)/$i)): \
102        $(IDLTESTFILES)
103    - $(MKDIR) $(MISC)/$(TARGET)
104    $(IDLC) -O$(MISC)/$(TARGET) -I$(SOLARIDLDIR) -cid -we $<
105
106.ENDIF
107