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)) 26SRC := $(patsubst %.goal, %.java, $(FILTERED)) 27OUT := $(patsubst %.goal, %.output, $(FILTERED)) 28 29DEBUG := 30# Use this to enable some debugging. 31# DEBUG := --debug 32 33default : all 34 35.PHONY: all 36all : $(DIFFS) results 37 38# Display results of all .diff files. 39.PHONY: results 40results: ../bin/VerifyDiffs.class 41 @echo "" 42 @echo "=== RESULTS ===" 43 @echo "" 44 @$(JAVA) -cp bin:../bin VerifyDiffs --show_all 45 46# Remakes the little java program that checks and compares diffs 47../bin/VerifyDiffs.class : ../VerifyDiffs.java 48 @$(JAVAC) -g -cp ../../bincompile -d ../bin ../VerifyDiffs.java 49 50# Compiles all the test cases (be verbose about this). 51.PHONY: compile 52compile : $(SRC) 53 mkdir -p bin 54 $(JAVAC) -g -cp ../../bin -d bin $(SRC) 55 56# Compiles just one test case 57.PRECIOUS : bin/annotator/tests/%.class 58bin/annotator/tests/%.class: %.java 59 mkdir -p bin 60 $(JAVAC) -g -cp bin:../../bin -d bin -sourcepath . $< 61 62# Actually runs the annotator to create the annotated java file. 63.PRECIOUS: %.output 64%.output: %.jaif %.java bin/annotator/tests/%.class ../../lib/plume-core.jar ../../bin ../../annotation-file-utilities.jar 65 $(JAVA) \ 66 -cp ../../bin:../../annotation-file-utilities.jar:bin \ 67 annotator.Main \ 68 ${DEBUG} \ 69 --abbreviate=false \ 70 -d $*-output \ 71 $*.jaif \ 72 $*.java \ 73 2>&1 | tee $*.log 74 find "$*-output" -name '*.java' -print | xargs cat > "$*.output" 75 rm -rf $*-output 76 77# Compare the output of the annotator and the goal file. 78%.diff: %.goal %.output 79 -diff -u $*.goal $*.output >& $*.diff 80 81# Remove all .diff, .log files from the tests directory. 82.PHONY: clean 83clean : 84 rm -rf bin 85 rm -f *.diff 86 rm -f *.log 87 rm -f *.output 88