1*7871dc3eSAndrew Rist#************************************************************** 2*7871dc3eSAndrew Rist# 3*7871dc3eSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*7871dc3eSAndrew Rist# or more contributor license agreements. See the NOTICE file 5*7871dc3eSAndrew Rist# distributed with this work for additional information 6*7871dc3eSAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*7871dc3eSAndrew Rist# to you under the Apache License, Version 2.0 (the 8*7871dc3eSAndrew Rist# "License"); you may not use this file except in compliance 9*7871dc3eSAndrew Rist# with the License. You may obtain a copy of the License at 10*7871dc3eSAndrew Rist# 11*7871dc3eSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12*7871dc3eSAndrew Rist# 13*7871dc3eSAndrew Rist# Unless required by applicable law or agreed to in writing, 14*7871dc3eSAndrew Rist# software distributed under the License is distributed on an 15*7871dc3eSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*7871dc3eSAndrew Rist# KIND, either express or implied. See the License for the 17*7871dc3eSAndrew Rist# specific language governing permissions and limitations 18*7871dc3eSAndrew Rist# under the License. 19*7871dc3eSAndrew Rist# 20*7871dc3eSAndrew Rist#************************************************************** 21*7871dc3eSAndrew Rist 22*7871dc3eSAndrew 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) 53cdf0e10cSrcweir 54cdf0e10cSrcweir.INCLUDE: settings.mk 55cdf0e10cSrcweir 56cdf0e10cSrcweir.IF "$(XCLASSPATH)" == "" 57cdf0e10cSrcweirXCLASSPATH := $(CLASSDIR) 58cdf0e10cSrcweir.ELSE 59cdf0e10cSrcweirXCLASSPATH !:= $(XCLASSPATH)$(PATH_SEPERATOR)$(CLASSDIR) 60cdf0e10cSrcweir.ENDIF 61cdf0e10cSrcweirCLASSDIR !:= $(CLASSDIR)/test 62cdf0e10cSrcweir 63cdf0e10cSrcweir.INCLUDE: target.mk 64cdf0e10cSrcweir 65cdf0e10cSrcweir$(JAVATARGET) : $(MISC)/$(TARGET).classdir.flag 66cdf0e10cSrcweir 67cdf0e10cSrcweir$(MISC)/$(TARGET).classdir.flag: 68cdf0e10cSrcweir - $(MKDIR) $(CLASSDIR) 69cdf0e10cSrcweir $(TOUCH) $@ 70cdf0e10cSrcweir 71cdf0e10cSrcweir.IF "$(JAVATESTFILES)" != "" 72cdf0e10cSrcweirALLTAR : test 73cdf0e10cSrcweir.END 74cdf0e10cSrcweir 75cdf0e10cSrcweir.IF "$(SOLAR_JAVA)" == "TRUE" && "$(OOO_JUNIT_JAR)" != "" 76cdf0e10cSrcweirtest .PHONY : $(JAVATARGET) 77cdf0e10cSrcweir $(JAVAI) $(JAVAIFLAGS) $(JAVACPS) \ 78cdf0e10cSrcweir '$(OOO_JUNIT_JAR)$(PATH_SEPERATOR)$(CLASSPATH)' \ 79cdf0e10cSrcweir org.junit.runner.JUnitCore \ 80cdf0e10cSrcweir $(foreach,i,$(JAVATESTFILES) $(subst,/,. $(PACKAGE)).$(i:s/.java//)) 81cdf0e10cSrcweir.ELSE 82cdf0e10cSrcweirtest .PHONY : 83cdf0e10cSrcweir echo 'test needs SOLAR_JAVA=TRUE and OOO_JUNIT_JAR' 84cdf0e10cSrcweir.END 85cdf0e10cSrcweir 86cdf0e10cSrcweir.IF "$(IDLTESTFILES)" != "" 87cdf0e10cSrcweir 88cdf0e10cSrcweir# The following dependency (to execute javac whenever javamaker has run) does 89cdf0e10cSrcweir# not work reliably, see #i28827#: 90cdf0e10cSrcweir$(JAVAFILES) $(JAVACLASSFILES): $(MISC)/$(TARGET).javamaker.flag 91cdf0e10cSrcweir 92cdf0e10cSrcweir$(MISC)/$(TARGET).javamaker.flag: $(MISC)/$(TARGET).rdb 93cdf0e10cSrcweir $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD $< -X$(SOLARBINDIR)/types.rdb 94cdf0e10cSrcweir $(TOUCH) $@ 95cdf0e10cSrcweir 96cdf0e10cSrcweir$(MISC)/$(TARGET).rdb .ERRREMOVE: \ 97cdf0e10cSrcweir $(foreach,i,$(IDLTESTFILES) $(subst,.idl,.urd $(MISC)/$(TARGET)/$i)) 98cdf0e10cSrcweir - rm $@ 99cdf0e10cSrcweir $(REGMERGE) $@ /UCR $< 100cdf0e10cSrcweir 101cdf0e10cSrcweir$(foreach,i,$(IDLTESTFILES) $(subst,.idl,.urd $(MISC)/$(TARGET)/$i)): \ 102cdf0e10cSrcweir $(IDLTESTFILES) 103cdf0e10cSrcweir - $(MKDIR) $(MISC)/$(TARGET) 104cdf0e10cSrcweir $(IDLC) -O$(MISC)/$(TARGET) -I$(SOLARIDLDIR) -cid -we $< 105cdf0e10cSrcweir 106cdf0e10cSrcweir.ENDIF 107