Makefile revision 30aa7ca0085e7a64fa39bba477ced3860f4fa874
1# Very rough testing framework for the annotator. Running 'make all' will 2# look for all myClass.goal files in this directory, run the annotator on the 3# corresponding .jaif and .java files, and then output the difference in a 4# myClass.diff file in this directory. 5# 6# To test just one file, use (for example) 'make myClass.diff'. 7 8# Put user-specific changes in your own Makefile.user. 9# Make will silently continue if that file does not exist. 10-include ../Makefile.user 11 12# Override these in Makefile.user if the java and javac commands are not on 13# your execution path. Example from Makefile.user: 14# JAVA=${JAVA_HOME}/bin/java 15# JAVAC=${JAVA_HOME}/bin/javac 16JAVA?=java 17JAVAC?=javac 18 19export SHELL=/bin/bash -o pipefail 20 21 22DIFFS := $(wildcard *.goal) 23DISABLED := $(shell grep -le "@skip-test" $(DIFFS)) 24FILTERED := $(filter-out $(DISABLED),$(DIFFS)) 25DIFFS := $(patsubst %.goal, %.diff, $(FILTERED)) 26AFU_JARS := ../../lib/plume-core.jar ../../annotation-file-utilities.jar 27JAIF := C.jaif 28SRC := $(patsubst %.goal, %.java, $(FILTERED)) 29OUT := $(patsubst %.goal, %.output, $(FILTERED)) 30 31DEBUG := 32# Use this to enable some debugging. 33# DEBUG := --debug 34 35default : all 36 37.PHONY: all 38all : $(DIFFS) results 39 40# Display results of all .diff files. 41.PHONY: results 42results: ../bin/VerifyDiffs.class 43 @rm -rf output 44 @echo "" 45 @echo "=== RESULTS ===" 46 @echo "" 47 @$(JAVA) -cp bin:../bin VerifyDiffs --show_all 48 49# Remakes the little java program that checks and compares diffs 50../bin/VerifyDiffs.class : ../VerifyDiffs.java 51 @$(JAVAC) -g -cp ../../bincompile -d ../bin ../VerifyDiffs.java 52 53# Compiles all the test cases (be verbose about this). 54.PHONY: compile 55compile : $(SRC) 56 mkdir -p bin 57 $(JAVAC) -g -cp bin:../../bin -d bin -sourcepath . $(SRC) 58 59# Actually runs the annotator to create the annotated java file. 60# We are required to put annotation-file-utilities.jar (and ../bin) on the 61# bootclasspath so that the JSR 308 javac classes bundled therein are found 62# before the stock javac classes that the Mac OS includes on the bootclasspath 63# (other platforms do not make such inclusions) 64output: compile $(JAIF) ../../bin $(AFU_JARS) 65 $(JAVA) \ 66 -Xbootclasspath/p:../../bin:../../annotation-file-utilities.jar \ 67 -cp bin \ 68 annotator.Main \ 69 ${DEBUG} \ 70 --abbreviate=true \ 71 -d output \ 72 $(JAIF) \ 73 $(SRC) \ 74 2>&1 | tee C.log 75 76.PRECIOUS: %.output 77%.output: output 78 find output -name "$*.java" -print | xargs cat > "$*.output" 79 80# Compare the output of the annotator and the goal file. 81%.diff: %.goal %.output 82 -diff -u $*.goal $*.output >& $*.diff 83 84# Remove all .diff, .log files from the tests directory. 85.PHONY: clean 86clean : 87 rm -rf bin 88 rm -f *.diff 89 rm -f *.log 90 rm -f *.output 91