Home | History | Annotate | Download | only in source-extension
      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
     16 JAVA?=java
     17 JAVAC?=javac
     18 
     19 export SHELL=/bin/bash -o pipefail
     20 
     21 
     22 DIFFS := $(wildcard *.goal)
     23 DISABLED := $(shell grep -le "@skip-test" $(DIFFS))
     24 FILTERED := $(filter-out $(DISABLED),$(DIFFS))
     25 DIFFS := $(patsubst %.goal, %.diff, $(FILTERED))
     26 SRC := $(patsubst %.goal, %.java, $(FILTERED))
     27 OUT := $(patsubst %.goal, %.output, $(FILTERED))
     28 
     29 DEBUG :=
     30 # Use this to enable some debugging.
     31 # DEBUG := --debug
     32 
     33 default : all
     34 
     35 .PHONY: all
     36 all : $(DIFFS) results
     37 
     38 # Display results of all .diff files.
     39 .PHONY: results
     40 results: ../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
     52 compile : $(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
     58 bin/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
     83 clean :
     84 	rm -rf bin
     85 	rm -f *.diff
     86 	rm -f *.log
     87 	rm -f *.output
     88