Skip to content

Commit

Permalink
7903323: Review and improve performance of jtreg reporting.
Browse files Browse the repository at this point in the history
Reviewed-by: iris
  • Loading branch information
jonathan-gibbons committed Sep 26, 2022
1 parent 66efe4b commit de2c216
Show file tree
Hide file tree
Showing 15 changed files with 663 additions and 6 deletions.
Expand Up @@ -50,6 +50,7 @@
import com.sun.javatest.finder.JavaCommentStream;
import com.sun.javatest.finder.ShScriptCommentStream;
import com.sun.javatest.finder.TagTestFinder;
import com.sun.javatest.regtest.agent.Flags;
import com.sun.javatest.regtest.exec.Action;
import com.sun.javatest.regtest.util.StringUtils;
import com.sun.javatest.util.I18NResourceBundle;
Expand Down Expand Up @@ -127,6 +128,10 @@ protected void setRoot(File testSuiteRoot) throws Fault {

@Override
protected void scanFile(File file) {
if (traceFinder) {
System.err.println("RegressionTestFinder: reading " + file);
}

try {
File tngRoot = properties.getTestNGRoot(file);
if (tngRoot != null) {
Expand Down Expand Up @@ -1058,4 +1063,6 @@ private static Pattern getOptionPattern(String name) {
private static final I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(RegressionTestFinder.class);
private static final boolean rejectTrailingBuild =
!Boolean.getBoolean("javatest.regtest.allowTrailingBuild");

private static final boolean traceFinder = Flags.get("traceFinder");
}
27 changes: 23 additions & 4 deletions src/share/classes/com/sun/javatest/regtest/tool/Tool.java
Expand Up @@ -393,7 +393,7 @@ public String[] getChoices() {
}

@Override
public void process(String opt, String arg) {
public void process(String opt, String arg) throws BadArgs {
switch (arg) {
case "none":
reportMode = ReportMode.NONE;
Expand All @@ -404,9 +404,14 @@ public void process(String opt, String arg) {
case "all-executed":
reportMode = ReportMode.ALL_EXECUTED;
break;
case "files":
reportMode = ReportMode.FILES;
break;
case "all":
reportMode = ReportMode.ALL;
break;
default:
throw new BadArgs(i18n, "main.badReportOption", arg);
}
}
},
Expand Down Expand Up @@ -1928,11 +1933,12 @@ public void error(String msg) {
default:
throw new IllegalStateException();

case EXECUTED:
case EXECUTED: {
ParameterFilter pf = new ParameterFilter();
pf.update(params);
tf = pf;
break;
}

case ALL_EXECUTED:
boolean[] statusValues = new boolean[Status.NUM_STATES];
Expand All @@ -1946,8 +1952,21 @@ public void error(String msg) {
case ALL:
tf = new AllTestsFilter();
break;
}

case FILES: {
try {
RegressionParameters reportParams = new RegressionParameters("regtest", params.getTestSuite(), out::println);
reportParams.setWorkDirectory(params.getWorkDirectory());
reportParams.setTests(params.getTests());
ParameterFilter pf = new ParameterFilter();
pf.update(reportParams);
tf = pf;
break;
} catch (Interview.Fault e) {
throw new Fault(i18n, "main.cantCreateReportParameters", e);
}
}
}
}
r.report(params, elapsedTimeHandler, stats, tf, quiet);
}
Expand Down Expand Up @@ -2247,7 +2266,7 @@ private static File getNormalizedFile(File f) {
private boolean guiFlag;
private boolean reportOnlyFlag;
private String showStream;
public enum ReportMode { NONE, EXECUTED, ALL_EXECUTED, ALL }
public enum ReportMode { NONE, EXECUTED, FILES, ALL_EXECUTED, ALL }
private ReportMode reportMode;
private boolean allowSetSecurityManagerFlag = true;
private static Verbose verbose;
Expand Down
Expand Up @@ -196,6 +196,8 @@ help.main.report.all-executed.desc=Include all tests that have been executed in
current work directory
help.main.report.all.desc=Include all tests that are present in the test suite, \
whether they have been executed
help.main.report.files.desc=Include all tests specified by groups and paths \
on the command line, ignoring filters like status, exclude lists, and keywords.
help.main.startHttpd.desc=Start the http server to view test results
help.main.showGroups.desc=Show the expansion (to files and directories) of the \
groups given on the command line. To see the expansion of all the groups \
Expand Down Expand Up @@ -444,12 +446,14 @@ main.badLockFile=Bad lock file: {0}
main.badMaxPoolSize=Bad value for maximum pool size: {0}
main.badParams=Bad parameters specified: {0}
main.badPoolIdleTimeout=Bad value for agent pool idle timeout: {0}
main.badReportOption=Bad value for -report: {0}
main.badRetainNone="none" cannot be combined with other options for -retain
main.badRetainLastRun="lastRun" cannot be combined with other options for -retain
main.badTestOrGroup=bad test or group specification: {0}
main.badTimeLimit=Bad value for -timeLimit
main.badTimeoutFactor=Bad use of -timeoutFactor
main.badTimeoutHandlerTimeout=Bad value for -timeoutHandlerTimeout
main.cantCreateReportParameters=Cannot create report parameters: {0}
main.cantCreateDir=Cannot create directory: {0}
main.cantCreateLockFile="Can''t create lock file: {0}
main.cantCreateParameters="Can''t create parameters: {0}
Expand Down
15 changes: 13 additions & 2 deletions src/share/doc/javatest/regtest/faq.md
Expand Up @@ -58,7 +58,7 @@ implement this specification, and is an older name for what is now known as

### What are the system requirements for using the JDK regression extensions?

It is recommended that you run jtreg using JDK 1.8 or later.
It is recommended that you run jtreg using JDK 11 or later.

### Where can I find a copy of jtreg?

Expand Down Expand Up @@ -559,7 +559,8 @@ The plain text files in the report directory include the following:
* `summary.txt`: summary of test results: one test per line, suitable for use with `grep`
* `timeStats.txt`: some statistics regarding test execution times

Reports can be disabled with the `-noreport` option.
Reports can be disabled with the `-noreport` option; the set of tests included
in the report can be selected with the `-report:`_value_ option.

It is generally recommended that the work and report directories should _not_ be
placed anywhere in the test suite itself. Since jtreg may scan the entire test suite
Expand Down Expand Up @@ -1091,6 +1092,16 @@ of the test execution times. If there are any tests taking an
unexpectedly long time to execute, they can be determined by examining
the `elapsed` entries in the `.jtr` files.

### Why is there a delay after the tests have been run, before jtreg exits?

By default, jtreg reports on all the tests that have been executed
and which have results in the work directory. It may take a few seconds
to find the set of tests for the report. You can use the `-report:`_value_
option to specify which tests should be in the report. If you are just
running a single test or a few tests, you may want to use `-report:files`,
to just report on the tests specified in the files and/or groups given on the
command line.

### How do I find the tests that took longest to run?

Using the [`elapsed`](#my-tests-take-a-long-time-to-run-how-do-i-find-where-the-time-goes)
Expand Down

0 comments on commit de2c216

Please sign in to comment.