Home | History | Annotate | Download | only in system-test
      1 # System test of annotation tools
      2 
      3 # This test runs most of the AFU tools, on a single program
      4 # source-ann/AnnotationTest.java that contains an annotation in every
      5 # possible location.
      6 
      7 ANNCAT ?= ../../../scene-lib/anncat
      8 JAVAVERSION = $(shell $(JAVA) -version 2>&1)
      9 ifeq (1.7.,$(findstring 1.7.,$(JAVAVERSION)))
     10   XJAVACTARGET = -source 7 -target 7
     11 endif
     12 
     13 #Switch the lines below to deactivate this test
     14 all: clean results
     15 #all: warn_and_exit
     16 
     17 warn_and_exit:
     18 	@echo ""
     19 	@echo "******************************************************"
     20 	@echo "Warning: The sytem test has been temporarily disabled!"
     21 	@echo "******************************************************"
     22 	@echo ""
     23 
     24 results: out1 check-out2 out3 out4.class check-out5
     25 
     26 clean:
     27 	rm -rf out[1-5]*
     28 
     29 
     30 # Step 1: Compile the source with annotations.
     31 out1:
     32 	mkdir out1
     33 	${XJAVAC} ${XJAVACTARGET} -d out1 source-ann/AnnotationTest.java || (\rm -rf out1 && false)
     34 
     35 # Step 2: Convert the annotated class file to an annotation file.
     36 # Do we get the right annotations?
     37 out2.jaif:
     38 	CLASSPATH=`pwd`/out1 ${ANNCAT} --class out1/annotations/tests/AnnotationTest.class --out --index out2.jaif
     39 
     40 out2.diff: out2.jaif
     41 	diff -u expected-annos.jaif out2.jaif > out2.diff
     42 
     43 .PHONY: check-out2
     44 # Fail if out2.diff is non-empty
     45 check-out2: out2.diff
     46 	[ ! -s out2.diff ] || (cat out2.diff && false)
     47 
     48 # Step 3: Compile the source without annotations.
     49 out3:
     50 	mkdir out3
     51 	${XJAVAC} ${XJAVACTARGET} -d out3 source-plain/AnnotationTest.java || (\rm -rf out3 && false)
     52 
     53 # Step 4: Insert annotations into the class file.
     54 # Can debug with:  javap -v out4.class
     55 out4.class: out3
     56 	CLASSPATH=`pwd`/out1 ${ANNCAT} --index expected-annos.jaif --out --class out3/annotations/tests/AnnotationTest.class --to out4.class
     57 
     58 # Step 5: Convert the annotation-inserted class file to an annotation file.
     59 # Do we get the right annotations?
     60 # (The annotation-compiled and annotation-inserted class files tend to differ
     61 # for stupid reasons (e.g., order of items in the constant pool), so we don't
     62 # compare them.)
     63 out5.jaif: out4.class
     64 	CLASSPATH=`pwd`/out1 ${ANNCAT} --class out4.class --out --index out5.jaif
     65 
     66 out5.diff: out5.jaif
     67 	diff -u expected-annos.jaif out5.jaif > out5.diff
     68 
     69 .PHONY: check-out5
     70 # Fail if out5.diff is non-empty
     71 check-out5: out5.diff
     72 	[ ! -s out5.diff ] || (cat out5.diff && false)
     73