diff -r a1112e2c3bc6 Makefile.am --- a/Makefile.am Fri Nov 23 11:31:19 2012 +0100 +++ b/Makefile.am Tue Nov 27 18:18:30 2012 +0100 @@ -20,6 +20,8 @@ export JUNIT_RUNNER_DIR=$(TESTS_DIR)/junit-runner export JUNIT_RUNNER_SRCDIR=$(TESTS_SRCDIR)/junit-runner +export JACOCO_OPERATOR_DIR=$(TESTS_DIR)/jacoco-operator +export JACOCO_OPERATOR_SRCDIR=$(TESTS_SRCDIR)/jacoco-operator export TEST_EXTENSIONS_SRCDIR=$(TESTS_SRCDIR)/test-extensions export TEST_EXTENSIONS_TESTS_SRCDIR=$(TESTS_SRCDIR)/test-extensions-tests @@ -55,6 +57,16 @@ export ALL_NONCUSTOM_REPRODUCERS=$(SIMPLE_REPRODUCERS) $(SIGNED_REPRODUCERS) export ALL_REPRODUCERS=$(ALL_NONCUSTOM_REPRODUCERS) $(CUSTOM_REPRODUCERS) +export JACOCO_PATH:=$(shell dirname "$(JACOCO_JAR)") +export JACOCO_AGENT=org.jacoco.agent.jar +export JACOCO_ANT=org.jacoco.ant.jar +export JACOCO_REPORT=org.jacoco.report.jar +export JACOCO_AGENTRT=org.jacoco.agent.rt.jar +export JACOCO_CORE=org.jacoco.core.jar +export JACOCO_CLASSPATH=$(JACOCO_PATH)/$(JACOCO_CORE):$(JACOCO_PATH)/$(JACOCO_AGENT):$(JACOCO_PATH)/$(JACOCO_REPORT):$(JACOCO_PATH)/$(JACOCO_AGENTRT):$(JACOCO_PATH)/$(JACOCO_ANT):$(ASM4_JAR) +export JACOCO_AGENT_SWITCH_BODY=-javaagent:$(JACOCO_PATH)/$(JACOCO_AGENTRT) +export JACOCO_AGENT_SWITCH="$(JACOCO_AGENT_SWITCH_BODY)=excludes=org.junit.*:junit.*" +export JACOCO_AGENT_JAVAWS_SWITCH=\"$(JACOCO_AGENT_SWITCH_BODY)=excludes=org.junit.*:junit.*:*jacoco*:java.lang.*:java.reflect.*:java.util.*,xboot=true,destfile=$(TESTS_DIR)/jacoco_javaws.exec\" # linking variables export PLUGIN_LINK_NAME=libjavaplugin.so @@ -587,6 +599,9 @@ junit-runner-source-files.txt: find $(JUNIT_RUNNER_SRCDIR) -name '*.java' | sort > $@ +jacoco-operator-source-files.txt: + find $(JACOCO_OPERATOR_SRCDIR) -name '*.java' | sort > $@ + $(JUNIT_RUNNER_JAR): junit-runner-source-files.txt stamps/test-extensions-compile.stamp mkdir -p $(JUNIT_RUNNER_DIR) && \ $(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \ @@ -1043,6 +1058,54 @@ endif touch $@ +stamps/compile-jacoco-operator: jacoco-operator-source-files.txt +if WITH_JACOCO + mkdir -p $(JACOCO_OPERATOR_DIR) && \ + $(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \ + -d $(JACOCO_OPERATOR_DIR) \ + -classpath $(JACOCO_CLASSPATH) \ + @jacoco-operator-source-files.txt ; +else + echo "Sorry, jacoco coverage report generator cant be compiled without jacoco installed. Try install jacoco or specify with-jacoco value" ; + exit 5 +endif + touch $@ + + +#warning, during this target tests.build/netx/unit/tests-output.xml is backup and rewriten (but not coresponding html file) +#xml results run from emma sandbox, however, can be wrong, co the new tests-output.xml is then renamed and orginal one restored +stamps/run-unit-test-code-coverage-jacoco.stamp: stamps/netx-unit-tests-compile.stamp $(JUNIT_RUNNER_JAR) \ + $(TESTS_DIR)/$(REPORT_STYLES_DIRNAME) $(UNIT_CLASS_NAMES) stamps/compile-jacoco-operator +if WITH_JACOCO + filename=" " ; \ + cd $(NETX_UNIT_TEST_SRCDIR) ; \ + for file in `find . -type f \! -iname "*.java"`; do\ + filename=`echo $$file `; \ + cp --parents $$filename $(NETX_UNIT_TEST_DIR) ; \ + done ; \ + cd $(NETX_UNIT_TEST_DIR) ; \ + for file in $(EMMA_MODIFIED_FILES) ; do \ + mv $(NETX_UNIT_TEST_DIR)/$$file $(NETX_UNIT_TEST_DIR)/"$$file""$(EMMA_BACKUP_SUFFIX)" ; \ + done ;\ + class_names=`cat $(UNIT_CLASS_NAMES)` ; \ + CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(TEST_EXTENSIONS_DIR):$(JACOCO_CLASSPATH):. \ + $(BOOT_DIR)/bin/java $(JACOCO_AGENT_SWITCH) -Xbootclasspath:$(RUNTIME) CommandLine $$class_names ; \ + for file in $(EMMA_MODIFIED_FILES) ; do \ + mv $(NETX_UNIT_TEST_DIR)/$$file $(NETX_UNIT_TEST_DIR)/"$$file""$(EMMA_SUFFIX)" ; \ + mv $(NETX_UNIT_TEST_DIR)/"$$file""$(EMMA_BACKUP_SUFFIX)" $(NETX_UNIT_TEST_DIR)/$$file ; \ + done ; \ + $(BOOT_DIR)/bin/java $(EMMA_JAVA_ARGS) -cp $(JACOCO_OPERATOR_DIR):$(JACOCO_CLASSPATH):. \ + org.jacoco.operator.Main \ + report --die-soon --html-output coverage --xml-output coverage.xml --input-file jacoco.exec \ + --input-srcs $(NETX_SRCDIR) $(PLUGIN_SRCDIR)/java $(NETX_UNIT_TEST_SRCDIR) $(JUNIT_RUNNER_SRCDIR) $(TEST_EXTENSIONS_SRCDIR) \ + --input-builds $(NETX_DIR)/lib/classes.jar $(abs_top_builddir)/liveconnect/lib/classes.jar $(NETX_UNIT_TEST_DIR) $(JUNIT_RUNNER_JAR) $(TEST_EXTENSIONS_DIR) \ + --title "IcedTea-Web unit-tests codecoverage" ; +else + echo "Sorry, coverage report cant be run without jacoco installed. Try install jacoco or specify with-jacoco value" ; + exit 5 +endif + touch $@ + #warning, during this target tests.build/netx/jnlp_testsengine/tests-output.xml is backup and rewriten (but not coresponding html file) #xml results run from emma sandbox, however, can be wrong, co the new tests-output.xml is then renamed and orginal one restored stamps/run-reproducers-test-code-coverage.stamp: stamps/run-netx-dist-tests.stamp $(REPRODUCERS_CLASS_NAMES) @@ -1133,6 +1196,92 @@ endif touch $@ + +#warning, during this target tests.build/netx/jnlp_testsengine/tests-output.xml is backup and rewriten (but not coresponding html file) +#xml results run from emma sandbox, however, can be wrong, co the new tests-output.xml is then renamed and orginal one restored +stamps/run-reproducers-test-code-coverage-jacoco.stamp: stamps/run-netx-dist-tests.stamp $(REPRODUCERS_CLASS_NAMES) stamps/compile-jacoco-operator +if WITH_JACOCO + cd $(TESTS_DIR) ; \ + for file in $(EMMA_MODIFIED_FILES) ; do \ + mv $(TEST_EXTENSIONS_DIR)/$$file $(TEST_EXTENSIONS_DIR)/"$$file""$(EMMA_BACKUP_SUFFIX)" ; \ + done ;\ + echo "backuping javaws in $(DESTDIR)" ; \ + javaws_backup=$(DESTDIR)$(bindir)/javaws_backup ; \ + mv $(DESTDIR)$(bindir)/javaws $$javaws_backup ; \ + echo "patching $(javaws)" ; \ + nw_bootclasspath="$(LAUNCHER_BOOTCLASSPATH):$(JACOCO_CLASSPATH)" ; \ + cat $$javaws_backup | sed "s|COMMAND.k.=\"..JAVA.\"|COMMAND[k]=\"\\$$\\{JAVA\\}\" ; k=1 ; COMMAND[k]=$(JACOCO_AGENT_JAVAWS_SWITCH)|" | sed "s,$(LAUNCHER_BOOTCLASSPATH),$$nw_bootclasspath," > $(DESTDIR)$(bindir)/$(javaws) ; \ + chmod 777 $(DESTDIR)$(bindir)/$(javaws) ; \ + testcases_srcs=( ) ; \ + k=0 ; \ + types=($(ALL_REPRODUCERS)); \ + for which in "$${types[@]}" ; do \ + . $(abs_top_srcdir)/NEW_LINE_IFS ; \ + simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-$$which.txt `); \ + IFS="$$IFS_BACKUP" ; \ + for dir in "$${simpleReproducers[@]}" ; do \ + testcases_srcs[k]="$(REPRODUCERS_TESTS_SRCDIR)/$$which/$$dir/testcases/" ; \ + k=$$((k+1)) ; \ + done ; \ + done ; \ + cd $(TEST_EXTENSIONS_DIR) ; \ + class_names=`cat $(REPRODUCERS_CLASS_NAMES)` ; \ + CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):.:$(TEST_EXTENSIONS_DIR):$(JACOCO_CLASSPATH):$(TEST_EXTENSIONS_TESTS_DIR) \ + $(BOOT_DIR)/bin/java $(JACOCO_AGENT_SWITCH) $(REPRODUCERS_DPARAMETERS) \ + -Xbootclasspath:$(RUNTIME) CommandLine $$class_names ; \ + $(BOOT_DIR)/bin/java $(EMMA_JAVA_ARGS) -cp $(JACOCO_OPERATOR_DIR):$(JACOCO_CLASSPATH):. \ + org.jacoco.operator.Main merge \ + --die-soon --input-files jacoco.exec $(TESTS_DIR)/jacoco_javaws.exec --output-file jacoco-merged-reproducers.exec ; \ + $(BOOT_DIR)/bin/java $(EMMA_JAVA_ARGS) -cp $(JACOCO_OPERATOR_DIR):$(JACOCO_CLASSPATH):. \ + org.jacoco.operator.Main \ + report --html-output coverage --xml-output coverage.xml --input-file jacoco-merged-reproducers.exec \ + --input-srcs $(NETX_SRCDIR) $(PLUGIN_SRCDIR)/java $(JUNIT_RUNNER_SRCDIR) $(TEST_EXTENSIONS_SRCDIR) $(TEST_EXTENSIONS_TESTS_SRCDIR) "$${testcases_srcs[@]}" \ + --input-builds $(NETX_DIR)/lib/classes.jar $(abs_top_builddir)/liveconnect/lib/classes.jar $(JUNIT_RUNNER_JAR) $(TEST_EXTENSIONS_DIR) $(TEST_EXTENSIONS_TESTS_DIR) \ + --title "IcedTea-Web reproducers-tests codecoverage" ; \ + echo "restoring javaws in $(DESTDIR)" ; \ + rm -f $(DESTDIR)$(bindir)/$(javaws); \ + mv $$javaws_backup $(DESTDIR)$(bindir)/$(javaws); \ + for file in $(EMMA_MODIFIED_FILES) ; do \ + mv $(TEST_EXTENSIONS_DIR)/$$file $(TEST_EXTENSIONS_DIR)/"$$file""$(EMMA_SUFFIX)" ; \ + mv $(TEST_EXTENSIONS_DIR)/"$$file""$(EMMA_BACKUP_SUFFIX)" $(TEST_EXTENSIONS_DIR)/$$file ; \ + done ; +else + echo "Sorry, coverage report cant be run without jacoco installed. Try install jacoco or specify with-jacoco value" ; + exit 5 +endif + touch $@ + +run-test-code-coverage-jacoco: run-unit-test-code-coverage-jacoco run-reproducers-test-code-coverage-jacoco +if WITH_JACOCO + cd $(TESTS_DIR) ; \ + k=0 ; \ + types=($(ALL_REPRODUCERS)); \ + for which in "$${types[@]}" ; do \ + . $(abs_top_srcdir)/NEW_LINE_IFS ; \ + simpleReproducers=(`cat $(abs_top_builddir)/junit-jnlp-dist-$$which.txt `); \ + IFS="$$IFS_BACKUP" ; \ + for dir in "$${simpleReproducers[@]}" ; do \ + testcases_srcs[k]="$(REPRODUCERS_TESTS_SRCDIR)/$$which/$$dir/testcases/" ; \ + k=$$((k+1)) ; \ + done ; \ + done ; \ + class_names=`cat $(REPRODUCERS_CLASS_NAMES)` ; \ + $(BOOT_DIR)/bin/java $(EMMA_JAVA_ARGS) -cp $(JACOCO_OPERATOR_DIR):$(JACOCO_CLASSPATH):. \ + org.jacoco.operator.Main merge \ + --die-soon --input-files $(TEST_EXTENSIONS_DIR)/jacoco-merged-reproducers.exec $(NETX_UNIT_TEST_DIR)/jacoco.exec --output-file jacoco-merged.exec; \ + $(BOOT_DIR)/bin/java $(EMMA_JAVA_ARGS) -cp $(JACOCO_OPERATOR_DIR):$(JACOCO_CLASSPATH):. \ + org.jacoco.operator.Main \ + report --html-output coverage --xml-output coverage.xml --input-file jacoco-merged.exec \ + --input-srcs $(NETX_SRCDIR) $(PLUGIN_SRCDIR)/java $(JUNIT_RUNNER_SRCDIR) $(TEST_EXTENSIONS_SRCDIR) $(TEST_EXTENSIONS_TESTS_SRCDIR) "$${testcases_srcs[@]}" \ + --input-builds $(NETX_DIR)/lib/classes.jar $(abs_top_builddir)/liveconnect/lib/classes.jar $(JUNIT_RUNNER_JAR) $(TEST_EXTENSIONS_DIR) $(TEST_EXTENSIONS_TESTS_DIR) \ + --input-srcs $(NETX_UNIT_TEST_SRCDIR) \ + --input-builds $(NETX_UNIT_TEST_DIR) \ + --title "IcedTea-Web complete codecoverage" ; \ +else + echo "Sorry, coverage report cant be run without jacoco installed. Try install jacoco or specify with-jacoco value" ; + exit 5 +endif + run-test-code-coverage: run-unit-test-code-coverage run-reproducers-test-code-coverage if WITH_EMMA cd $(TESTS_DIR) ; \ @@ -1368,3 +1517,7 @@ run-unit-test-code-coverage: stamps/run-unit-test-code-coverage.stamp run-reproducers-test-code-coverage: stamps/run-reproducers-test-code-coverage.stamp + +run-unit-test-code-coverage-jacoco: stamps/run-unit-test-code-coverage-jacoco.stamp + +run-reproducers-test-code-coverage-jacoco: stamps/run-reproducers-test-code-coverage-jacoco.stamp diff -r a1112e2c3bc6 configure.ac --- a/configure.ac Fri Nov 23 11:31:19 2012 +0100 +++ b/configure.ac Tue Nov 27 18:18:30 2012 +0100 @@ -106,6 +106,10 @@ [/usr/share/java/junit4.jar /usr/share/junit-4/lib/junit.jar]) IT_FIND_OPTIONAL_JAR([emma], EMMA, [/usr/share/java/emma.jar]) +IT_FIND_OPTIONAL_JAR([jacoco], JACOCO, + [/usr/share/java/jacoco/org.jacoco.core.jar]) +IT_FIND_OPTIONAL_JAR([asm4], ASM4, + [/usr/share/java/objectweb-asm4/asm-all-4.0.jar]) AC_CONFIG_FILES([jrunscript], [chmod u+x jrunscript]) AC_CONFIG_FILES([build.properties])