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. 60output: compile $(JAIF) ../../bin $(AFU_JARS) 61 $(JAVA) \ 62 -cp ../../bin:../../annotation-file-utilities.jar:bin \ 63 annotator.Main \ 64 ${DEBUG} \ 65 --abbreviate=true \ 66 -d output \ 67 $(JAIF) \ 68 $(SRC) \ 69 2>&1 | tee C.log 70 71.PRECIOUS: %.output 72%.output: output 73 find output -name "$*.java" -print | xargs cat > "$*.output" 74 75# Compare the output of the annotator and the goal file. 76%.diff: %.goal %.output 77 -diff -u $*.goal $*.output >& $*.diff 78 79# Remove all .diff, .log files from the tests directory. 80.PHONY: clean 81clean : 82 rm -rf bin 83 rm -f *.diff 84 rm -f *.log 85 rm -f *.output 86