xref: /aoo42x/main/solenv/inc/javaunittest.mk (revision 67dc21e5)
17871dc3eSAndrew Rist#**************************************************************
27871dc3eSAndrew Rist#
37871dc3eSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
47871dc3eSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
57871dc3eSAndrew Rist#  distributed with this work for additional information
67871dc3eSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
77871dc3eSAndrew Rist#  to you under the Apache License, Version 2.0 (the
87871dc3eSAndrew Rist#  "License"); you may not use this file except in compliance
97871dc3eSAndrew Rist#  with the License.  You may obtain a copy of the License at
107871dc3eSAndrew Rist#
117871dc3eSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
127871dc3eSAndrew Rist#
137871dc3eSAndrew Rist#  Unless required by applicable law or agreed to in writing,
147871dc3eSAndrew Rist#  software distributed under the License is distributed on an
157871dc3eSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
167871dc3eSAndrew Rist#  KIND, either express or implied.  See the License for the
177871dc3eSAndrew Rist#  specific language governing permissions and limitations
187871dc3eSAndrew Rist#  under the License.
197871dc3eSAndrew Rist#
207871dc3eSAndrew Rist#**************************************************************
217871dc3eSAndrew Rist
227871dc3eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir# Makefile template for directories that contain Java unit tests.
25cdf0e10cSrcweir#
26cdf0e10cSrcweir# Before including this makefile, the following variables should be set:
27cdf0e10cSrcweir# - PRJ, PRJNAME, TARGET
28cdf0e10cSrcweir# - PACKAGE
29cdf0e10cSrcweir# - JAVATESTFILES: the unit test classes;
30cdf0e10cSrcweir#     each one of the form <basename>.java;
31cdf0e10cSrcweir#     these java files must only define classes within the package corresponding
32cdf0e10cSrcweir#     to PACKAGE, the name of each defined (outer) class should end with "_Test"
33cdf0e10cSrcweir# - JAVAFILES: optional java files, corresponding class files are generated
34cdf0e10cSrcweir#     that can be used when compiling or running the tests;
35cdf0e10cSrcweir#     each one of the form <basename>.java;
36cdf0e10cSrcweir#     these java files must only define classes within the package corresponding
37cdf0e10cSrcweir#     to PACKAGE, the name of each defined (outer) class should start with
38cdf0e10cSrcweir#     "Test"
39cdf0e10cSrcweir# - IDLTESTFILES: optional idl files, corresponding class files are generated
40cdf0e10cSrcweir#     that can be used when compiling or running the tests;
41cdf0e10cSrcweir#     each one of the form <basename>.idl;
42cdf0e10cSrcweir#     these idl files must only define entities within the module corresponding
43cdf0e10cSrcweir#     to PACKAGE, the name of each defined entity should start with "Test"
44cdf0e10cSrcweir# - JARFILES: optional jar files that can be used when compiling or running the
45cdf0e10cSrcweir#     tests;
46cdf0e10cSrcweir#     each one of the form <basename>.jar
47cdf0e10cSrcweir# All generated class files are placed into <platform>/class/test/ instead of
48cdf0e10cSrcweir# <platform>/class/, so that they are not accidentally included in jar files
49cdf0e10cSrcweir# packed from <platform>/class/ subdirectories.
50cdf0e10cSrcweir
51cdf0e10cSrcweirJAVAFILES +:= $(JAVATESTFILES)
52cdf0e10cSrcweirEXTRAJARFILES += $(OOO_JUNIT_JAR)
53*67dc21e5SDamjan Jovanovic.IF "$(HAMCREST_CORE_JAR)" != ""
54*67dc21e5SDamjan JovanovicEXTRAJARFILES += $(HAMCREST_CORE_JAR)
55*67dc21e5SDamjan Jovanovic.END
56cdf0e10cSrcweir
57cdf0e10cSrcweir.INCLUDE: settings.mk
58cdf0e10cSrcweir
59cdf0e10cSrcweir.IF "$(XCLASSPATH)" == ""
60cdf0e10cSrcweirXCLASSPATH := $(CLASSDIR)
61cdf0e10cSrcweir.ELSE
62cdf0e10cSrcweirXCLASSPATH !:= $(XCLASSPATH)$(PATH_SEPERATOR)$(CLASSDIR)
63cdf0e10cSrcweir.ENDIF
64cdf0e10cSrcweirCLASSDIR !:= $(CLASSDIR)/test
65cdf0e10cSrcweir
66cdf0e10cSrcweir.INCLUDE: target.mk
67cdf0e10cSrcweir
68cdf0e10cSrcweir$(JAVATARGET) : $(MISC)/$(TARGET).classdir.flag
69cdf0e10cSrcweir
70cdf0e10cSrcweir$(MISC)/$(TARGET).classdir.flag:
71cdf0e10cSrcweir    - $(MKDIR) $(CLASSDIR)
72cdf0e10cSrcweir    $(TOUCH) $@
73cdf0e10cSrcweir
74cdf0e10cSrcweir.IF "$(JAVATESTFILES)" != ""
75cdf0e10cSrcweirALLTAR : test
76cdf0e10cSrcweir.END
77cdf0e10cSrcweir
78cdf0e10cSrcweir.IF "$(SOLAR_JAVA)" == "TRUE" && "$(OOO_JUNIT_JAR)" != ""
79*67dc21e5SDamjan Jovanovic.IF "$(HAMCREST_CORE_JAR)" != ""
80*67dc21e5SDamjan Jovanovictest .PHONY : $(JAVATARGET)
81*67dc21e5SDamjan Jovanovic    $(JAVAI) $(JAVAIFLAGS) $(JAVACPS) \
82*67dc21e5SDamjan Jovanovic        '$(OOO_JUNIT_JAR)$(PATH_SEPERATOR)$(HAMCREST_CORE_JAR)$(PATH_SEPARATOR)$(CLASSPATH)' \
83*67dc21e5SDamjan Jovanovic        org.junit.runner.JUnitCore \
84*67dc21e5SDamjan Jovanovic        $(foreach,i,$(JAVATESTFILES) $(subst,/,. $(PACKAGE)).$(i:s/.java//))
85*67dc21e5SDamjan Jovanovic.ELSE
86cdf0e10cSrcweirtest .PHONY : $(JAVATARGET)
87cdf0e10cSrcweir    $(JAVAI) $(JAVAIFLAGS) $(JAVACPS) \
88cdf0e10cSrcweir        '$(OOO_JUNIT_JAR)$(PATH_SEPERATOR)$(CLASSPATH)' \
89cdf0e10cSrcweir        org.junit.runner.JUnitCore \
90cdf0e10cSrcweir        $(foreach,i,$(JAVATESTFILES) $(subst,/,. $(PACKAGE)).$(i:s/.java//))
91*67dc21e5SDamjan Jovanovic.END
92cdf0e10cSrcweir.ELSE
93cdf0e10cSrcweirtest .PHONY :
94cdf0e10cSrcweir    echo 'test needs SOLAR_JAVA=TRUE and OOO_JUNIT_JAR'
95cdf0e10cSrcweir.END
96cdf0e10cSrcweir
97cdf0e10cSrcweir.IF "$(IDLTESTFILES)" != ""
98cdf0e10cSrcweir
99cdf0e10cSrcweir# The following dependency (to execute javac whenever javamaker has run) does
100cdf0e10cSrcweir# not work reliably, see #i28827#:
101cdf0e10cSrcweir$(JAVAFILES) $(JAVACLASSFILES): $(MISC)/$(TARGET).javamaker.flag
102cdf0e10cSrcweir
103cdf0e10cSrcweir$(MISC)/$(TARGET).javamaker.flag: $(MISC)/$(TARGET).rdb
104cdf0e10cSrcweir    $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD $< -X$(SOLARBINDIR)/types.rdb
105cdf0e10cSrcweir    $(TOUCH) $@
106cdf0e10cSrcweir
107cdf0e10cSrcweir$(MISC)/$(TARGET).rdb .ERRREMOVE: \
108cdf0e10cSrcweir        $(foreach,i,$(IDLTESTFILES) $(subst,.idl,.urd $(MISC)/$(TARGET)/$i))
109cdf0e10cSrcweir    - rm $@
110cdf0e10cSrcweir    $(REGMERGE) $@ /UCR $<
111cdf0e10cSrcweir
112cdf0e10cSrcweir$(foreach,i,$(IDLTESTFILES) $(subst,.idl,.urd $(MISC)/$(TARGET)/$i)): \
113cdf0e10cSrcweir        $(IDLTESTFILES)
114cdf0e10cSrcweir    - $(MKDIR) $(MISC)/$(TARGET)
115cdf0e10cSrcweir    $(IDLC) -O$(MISC)/$(TARGET) -I$(SOLARIDLDIR) -cid -we $<
116cdf0e10cSrcweir
117cdf0e10cSrcweir.ENDIF
118