From db91be2ee1c84a3051f10b1ccc32d0abc7d0292d Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Thu, 5 Mar 2020 09:51:03 -0800 Subject: [PATCH] 8240241: Add support for JCov DiffCoverage to make files Reviewed-by: erikj, ihse --- doc/testing.html | 3 +++ doc/testing.md | 12 +++++++++++- make/RunTests.gmk | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/doc/testing.html b/doc/testing.html index 143ced088f7..bb7974cac60 100644 --- a/doc/testing.html +++ b/doc/testing.html @@ -127,6 +127,9 @@ TEST FAILURE

The simplest way to run tests with JCov coverage report is to use the special target jcov-test instead of test, e.g. make jcov-test TEST=jdk_lang. This will make sure the JCov image is built, and that JCov reporting is enabled.

The JCov report is stored in build/$BUILD/test-results/jcov-output.

Please note that running with JCov reporting can be very memory intensive.

+

JCOV_DIFF_CHANGESET

+

While collecting code coverage with JCov, it is also possible to find coverage for only recently changed code. JCOV_DIFF_CHANGESET specifies a source revision. A textual report will be generated showing coverage of the diff between the specified revision and the repository tip.

+

The report is stored in build/$BUILD/test-results/jcov-output/diff_coverage_report file.

JTReg keywords

JOBS

The test concurrency (-concurrency).

diff --git a/doc/testing.md b/doc/testing.md index dfd67157e90..f3d2a9e2993 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -241,10 +241,20 @@ The simplest way to run tests with JCov coverage report is to use the special target `jcov-test` instead of `test`, e.g. `make jcov-test TEST=jdk_lang`. This will make sure the JCov image is built, and that JCov reporting is enabled. -The JCov report is stored in `build/$BUILD/test-results/jcov-output`. +The JCov report is stored in `build/$BUILD/test-results/jcov-output/report`. Please note that running with JCov reporting can be very memory intensive. +#### JCOV_DIFF_CHANGESET + +While collecting code coverage with JCov, it is also possible to find coverage +for only recently changed code. JCOV_DIFF_CHANGESET specifies a source +revision. A textual report will be generated showing coverage of the diff +between the specified revision and the repository tip. + +The report is stored in `build/$BUILD/test-results/jcov-output/diff_coverage_report` +file. + ### JTReg keywords #### JOBS diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 121cdc09fa0..b3ce833bb41 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -45,7 +45,7 @@ ifneq ($(TEST_VM_OPTS), ) endif $(eval $(call ParseKeywordVariable, TEST_OPTS, \ - SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR JCOV, \ + SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR JCOV JCOV_DIFF_CHANGESET, \ STRING_KEYWORDS := VM_OPTIONS JAVA_OPTIONS AOT_MODULES, \ )) @@ -1266,12 +1266,44 @@ ifeq ($(TEST_OPTS_JCOV), true) TARGETS += jcov-do-start-grabber jcov-start-grabber jcov-stop-grabber \ jcov-gen-report + ifneq ($(TEST_OPTS_JCOV_DIFF_CHANGESET), ) + + JCOV_SOURCE_DIFF := $(JCOV_OUTPUT_DIR)/source_diff + JCOV_DIFF_COVERAGE_REPORT := $(JCOV_OUTPUT_DIR)/diff_coverage_report + + ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), ) + DIFF_COMMAND := $(HG) -R $(TOPDIR) diff -r $(TEST_OPTS_JCOV_DIFF_CHANGESET) > $(JCOV_SOURCE_DIFF) + else ifneq ($(and $(GIT), $(wildcard $(TOPDIR)/.git)), ) + DIFF_COMMAND := $(GIT) -C $(TOPDIR) diff $(TEST_OPTS_JCOV_DIFF_CHANGESET) > $(JCOV_SOURCE_DIFF) + else + $(info Error: Must be either hg or git source tree for diff coverage.) + $(error Neither hg nor git source tree.) + endif + + jcov-gen-diffcoverage: jcov-stop-grabber + $(call LogWarn, Generating diff coverage with changeset $(TEST_OPTS_JCOV_DIFF_CHANGESET) ... ) + $(DIFF_COMMAND) + $(JAVA) -Xmx4g -jar $(JCOV_HOME)/lib/jcov.jar \ + DiffCoverage -replaceDiff "src/.*/classes/:" -all \ + $(JCOV_RESULT_FILE) $(JCOV_SOURCE_DIFF) > \ + $(JCOV_DIFF_COVERAGE_REPORT) + + TARGETS += jcov-gen-diffcoverage + + endif + # Hook this into the framework at appropriate places pre-run-test: jcov-start-grabber post-run-test: jcov-gen-report - jcov-gen-report: run-all-tests + ifneq ($(TEST_OPTS_JCOV_DIFF_CHANGESET), ) + + post-run-test: jcov-gen-diffcoverage + + endif + + jcov-stop-grabber: run-all-tests endif