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 16export JAVA?=java -ea 17export JAVAC?=javac 18export XJAVAC?=javac 19 20export SHELL=/bin/bash -o pipefail 21 22 23DIFFS := $(wildcard *.goal) 24DISABLED := $(shell grep -le "@skip-test" $(DIFFS)) 25FILTERED := $(filter-out $(DISABLED),$(DIFFS)) 26DIFFS := $(patsubst %.goal, %.diff, $(FILTERED)) 27 28DEBUG := 29# Use this to enable some debugging. 30# DEBUG := --debug 31 32default : all 33 34.PHONY: all 35all : $(DIFFS) abbreviated ad-hoc system-test source-extension results 36 37.PHONY: abbreviated 38abbreviated: 39 ${MAKE} -C abbreviated 40 41.PHONY: ad-hoc 42ad-hoc: 43 ${MAKE} -C ad-hoc 44 45.PHONY: source-extension 46source-extension: 47 ${MAKE} -C source-extension 48 49.PHONY: system-test 50system-test: 51 ${MAKE} -C system-test 52 53# Display results of all .diff files. 54.PHONY: results 55results: bin/VerifyDiffs.class 56 @echo "" 57 @echo "=== RESULTS ===" 58 @echo "" 59 @$(JAVA) -cp bin VerifyDiffs --show_all 60 61# Remakes the little java program that checks and compares diffs 62bin/VerifyDiffs.class : VerifyDiffs.java 63 @$(JAVAC) -g -cp ../bincompile -d bin VerifyDiffs.java 64 65# Compiles all the test cases (be verbose about this). 66compile : 67 mkdir -p bin 68 $(XJAVAC) -g -cp ../bin -d bin *.java 69 70.PRECIOUS : bin/annotator/tests/%.class 71bin/annotator/tests/%.class: %.java 72 mkdir -p bin 73# Added "-Xlint:-options" to see if it permits Jenkins job to succeed, due to 74# problem "target value 1.8 is obsolete and will be removed in a future release" 75 $(XJAVAC) -Xlint:-options -g -cp bin:../annotation-file-utilities.jar -d bin -sourcepath . $*.java 76 77# Actually runs the annotator to create the annotated java file. 78.PRECIOUS: %.output 79%.output: %.jaif %.java bin/annotator/tests/%.class ../lib/plume-core.jar ../bin ../annotation-file-utilities.jar 80 $(JAVA) \ 81 -cp ../bin:../annotation-file-utilities.jar:bin \ 82 annotator.Main \ 83 ${DEBUG} \ 84 --abbreviate=false \ 85 -d $*-output \ 86 $*.jaif \ 87 $*.java \ 88 2>&1 | tee $*.log 89 find "$*-output" -name '*.java' -print | xargs cat > "$*.output" 90 rm -rf $*-output 91 92# Compare the output of the annotator and the goal file. 93%.diff: %.goal %.output 94 -diff -u $*.goal $*.output >& $*.diff 95 96# Remove all .diff, .log files from the tests directory. 97.PHONY: clean 98clean : 99 rm -rf bin 100 rm -f *.diff 101 rm -f *.log 102 rm -f *.output 103 (cd abbreviated && make clean) 104 (cd ad-hoc && make clean) 105