Skip to content
Commits on Source (2)
/build/
/webrev
.DS_Store
/.idea/
repo: 9f51ef22f00a3d5b681472cacf3ce15868073103
node: ec37d2900cd42987270f98423a60eb6297bdc37b
node: deee95d5d8ff6406b77c0d5b9297736eb7c98c6d
branch: default
tag: jtreg4.2-b14
tag: jtreg4.2-b16
......@@ -27,3 +27,4 @@ cce0ac75e87864ed365a420fb836a4430421ab0f jtreg4.2-b08
a13ec77e7adcc4c9ed434e664abc350abaacc045 jtreg4.2-b11
652902f7fb0ed0b4f307d61a799caf50a6e609be jtreg4.2-b12
7a38f21e077821a5015792e85b3793c90c81b866 jtreg4.2-b13
ec37d2900cd42987270f98423a60eb6297bdc37b jtreg4.2-b14
#
# Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,6 @@
# questions.
#
#---------------------------------------------------------------------
#
# Copy resources (*.properties) into classes directory from source tree
......@@ -71,9 +70,10 @@ $(IMAGES_DIR)/%.jar: pkgsToFiles.sh
echo "$(@F:%.jar=%)-BuildDate: `/bin/date +'%B %d, %Y'`" ; \
) \
> $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/manifest.txt)
sh pkgsToFiles.sh $(CLASSDIR) $($(@F:%.jar=PKGS.JAR.%)) > $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/includes.txt)
$(JAR) -cmf $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/manifest.txt) $@ \
$(JAR_COPYRIGHT) \
`sh pkgsToFiles.sh $(CLASSDIR) $($(@F:%.jar=PKGS.JAR.%))` \
@$(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/includes.txt) \
$(patsubst $(CLASSDIR)/%,-C $(CLASSDIR) %,$(sort $(FILES.JAR.$(@F:%.jar=%)))) \
$(JAR_EXTRAS)
$(CHMOD) a-w $@
......
#!/bin/bash
#
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -50,12 +50,51 @@ if case ${JAVA_VERSION} in 1.8*) false ;; *) true; esac; then
exit 1
fi
case `uname` in CYGWIN*) CYGWIN=1 ;; *) CYGWIN=0 ;; esac
native_path() {
if [ $CYGWIN == 1 ]; then echo `cygpath -w $1`; else echo $1; fi
}
mixed_path() {
if [ $CYGWIN == 1 ]; then echo `cygpath -m $1`; else echo $1; fi
}
get_scm_type() {
if [ -d .hg ]; then
echo "HG"
elif [ -d .git ]; then
echo "GIT"
else
echo "Error: unrecognized repository, it must be Git or Mercurial" >&2
exit 1
fi
}
SCM_TYPE=`get_scm_type`
get_root() {
case $SCM_TYPE in
HG) hg root ;;
GIT) git rev-parse --show-toplevel ;;
*) echo "Error: unknown SCM" >&2 ; exit 1 ;;
esac
}
get_tag_info() {
case $SCM_TYPE in
HG) hg tags | grep jtreg | head -1 ;;
GIT) git tag | grep jtreg | tail -1 ;;
*) echo "Error: unknown SCM" >&2 ; exit 1 ;;
esac
}
export JAVA_HOME=$1
export PATH="$JAVA_HOME:$PATH"
if [ -n `which sha1sum` ]; then
if [ -n "`which sha1sum`" ]; then
SHASUM=sha1sum;
elif [ -n `which shasum` ]; then
elif [ -n "`which shasum`" ]; then
SHASUM="shasum -a 1"
else
echo "Error: can't find shasum or sha1sum" >&2
......@@ -67,7 +106,9 @@ UNZIP_OPTS="${UNZIP_OPTS:--q} -u"
WGET=wget
WGET_OPTS=${WGET_OPTS:--q}
ROOT=$(hg root)
ROOT=`get_root`
BUILD_DIR=${BUILD_DIR:-${ROOT}/build}
if [ "${SKIP_WGET:-}" = "" -a -d ${BUILD_DIR} ]; then
......@@ -129,7 +170,7 @@ fi
ASMTOOLS_SRC=${ASMTOOLS_BUILD_DIR}/asmtools-${ASMTOOLS_VERSION}
ASMTOOLS_DIST=${ASMTOOLS_BUILD_DIR}/build
${ANT} -DBUILD_DIR=${ASMTOOLS_DIST} -f ${ASMTOOLS_SRC}/build/build.xml
${ANT} -DBUILD_DIR=`native_path ${ASMTOOLS_DIST}` -f `native_path ${ASMTOOLS_SRC}/build/build.xml`
ASMTOOLS_JAR=${ASMTOOLS_DIST}/binaries/lib/asmtools.jar
ASMTOOLS_LICENSE=${ASMTOOLS_SRC}/LICENSE
......@@ -150,7 +191,7 @@ fi
JTHARNESS_SRC=${JTHARNESS_BUILD_DIR}/jtharness-${JTHARNESS_VERSION}
JTHARNESS_DIST=${JTHARNESS_BUILD_DIR}/build
${ANT} -DBUILD_DIR=${JTHARNESS_DIST} -f ${JTHARNESS_SRC}/build/build.xml
${ANT} -DBUILD_DIR=`native_path ${JTHARNESS_DIST}` -f `native_path ${JTHARNESS_SRC}/build/build.xml`
JAVATEST_JAR=${JTHARNESS_DIST}/binaries/lib/javatest.jar
JTHARNESS_LICENSE=${JTHARNESS_SRC}/legal/license.txt
......@@ -193,16 +234,16 @@ fi
JCOV_SRC=${JCOV_BUILD_DIR}/jcov-${JCOV_VERSION}
JCOV_DIST=${JCOV_BUILD_DIR}/build
( cd ${JCOV_SRC}/build
${ANT} -Dresult.dir=${JCOV_DIST} \
-Dasm.jar=${ASM_JAR} \
${ANT} -Dresult.dir=`native_path ${JCOV_DIST}` \
-Dasm.jar=`native_path ${ASM_JAR}` \
-Dasm.checksum=${ASM_JAR_CHECKSUM} \
-Dasm.tree.jar=${ASM_TREE_JAR} \
-Dasm.tree.jar=`native_path ${ASM_TREE_JAR}` \
-Dasm.tree.checksum=${ASM_TREE_JAR_CHECKSUM} \
-Dasm.util.jar=${ASM_UTIL_JAR} \
-Dasm.util.jar=`native_path ${ASM_UTIL_JAR}` \
-Dasm.util.checksum=${ASM_UTIL_JAR_CHECKSUM} \
-Djavatestjar=${JAVATEST_JAR} \
-Djavatestjar=`native_path ${JAVATEST_JAR}` \
-Dverify.strict= \
-f ${JCOV_SRC}/build/build.xml
-f `native_path ${JCOV_SRC}/build/build.xml`
)
JCOV_JAR=${JCOV_DIST}/jcov_3.0/jcov.jar
......@@ -244,26 +285,27 @@ echo "6375e521c1e11d6563d4f25a07ce124ccf8cd171 ${JCOMMANDER_JAR}" | ${SHASUM} -
## Set version and build numbers to the latest tagged version by default
TAG_INFO=`get_tag_info`
if [ -z ${BUILD_NUMBER:-} ]; then
BUILD_NUMBER=`hg tags | grep jtreg | head -1 | sed 's/jtreg\([0-9]\.[0-9]\)-\(b[0-9]*\).*/\2/'`
BUILD_NUMBER=`echo $TAG_INFO | sed 's/jtreg\([0-9]\.[0-9]\)-\(b[0-9]*\).*/\2/'`
fi
if [ -z ${BUILD_VERSION:-} ]; then
BUILD_VERSION=`hg tags | grep jtreg | head -1 | sed 's/jtreg\([0-9]\.[0-9]\)-\(b[0-9]*\).*/\1/'`
BUILD_VERSION=`echo $TAG_INFO | sed 's/jtreg\([0-9]\.[0-9]\)-\(b[0-9]*\).*/\1/'`
fi
# Build jtreg
cd ${ROOT}/make
make JUNIT_JAR=${JUNIT_JAR} \
make JUNIT_JAR=`mixed_path ${JUNIT_JAR}` \
JUNIT_LICENSE=${JUNIT_LICENSE} \
TESTNG_JAR=${TESTNG_JAR} \
TESTNG_JAR=`mixed_path ${TESTNG_JAR}` \
TESTNG_LICENSE=${TESTNG_LICENSE} \
JCOMMANDER_JAR=${JCOMMANDER_JAR} \
ANT=${ANT} \
ANT_JAR=${ANT_JAR} \
ANT_JAR=`mixed_path ${ANT_JAR}` \
JCOV_JAR=${JCOV_JAR} \
JCOV_LICENSE=${JCOV_LICENSE} \
JCOV_NETWORK_SAVER_JAR=${JCOV_NETWORK_SAVER_JAR} \
JAVATEST_JAR=${JAVATEST_JAR} \
JAVATEST_JAR=`mixed_path ${JAVATEST_JAR}` \
JTHARNESS_LICENSE=${JTHARNESS_LICENSE} \
JTHARNESS_COPYRIGHT=${JTHARNESS_COPYRIGHT} \
ASMTOOLS_JAR=${ASMTOOLS_JAR} \
......@@ -273,4 +315,3 @@ make JUNIT_JAR=${JUNIT_JAR} \
BUILD_NUMBER=${BUILD_NUMBER} \
JDKHOME=$JAVA_HOME \
${MAKE_ARGS:-}
......@@ -26,15 +26,14 @@
<idea-plugin>
<id>jtreg</id>
<name>jtreg Test Support</name>
<version>1.9</version>
<version>1.10</version>
<description><![CDATA[
Allows execution of tests developed using the <a href="http://openjdk.java.net/jtreg/">jtreg</a> framework.
]]></description>
<change-notes><![CDATA[
<ul>
<li>Add support for IntelliJ IDE2018.3</li>
<li>Allow support for external library resolution</li>
<li>Add support for IntelliJ IDE2019.3</li>
</ul>
]]>
</change-notes>
......
......@@ -41,7 +41,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Alarm;
import com.intellij.util.containers.hash.HashMap;
import com.oracle.plugin.jtreg.util.JTRegUtils;
import org.jetbrains.annotations.NotNull;
......
......@@ -38,6 +38,7 @@ import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.testframework.SearchForTestsTask;
import com.intellij.execution.testframework.TestSearchScope;
import com.intellij.execution.ui.DefaultJreSelector;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.projectRoots.JdkUtil;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
......@@ -150,7 +151,6 @@ class JTRegConfigurationRunnableState extends JavaTestFrameworkRunnableState<JTR
return javaParameters;
}
@Override
protected void configureRTClasspath(JavaParameters javaParameters) {
JTRegService jtregSettings = JTRegService.getInstance(getConfiguration().getProject());
javaParameters.getClassPath().add(jtregSettings.getJTRegDir() + "/lib/jtreg.jar");
......@@ -160,6 +160,10 @@ class JTRegConfigurationRunnableState extends JavaTestFrameworkRunnableState<JTR
javaParameters.getClassPath().add(jtregSettings.getJTRegDir() + "/lib/asmtools.jar");
}
protected void configureRTClasspath(JavaParameters javaParameters, Module module) throws CantRunException {
configureRTClasspath(javaParameters);
}
@Override
protected List<String> getNamedParams(String parameters) {
return Stream.of(parameters.split(" ")).collect(Collectors.toList());
......
......@@ -64,7 +64,7 @@
case "`uname -s`" in
CYGWIN* ) cygwin=1 ;;
Linux ) if grep -q Microsoft /proc/version ; then wsl=1 ; fi ;;
Linux ) if grep -qi Microsoft /proc/version ; then wsl=1 ; fi ;;
esac
......
......@@ -475,7 +475,7 @@ public class RegressionParameters
return matchListFilter;
}
TestFilter matchListFilter = UNSET;
private TestFilter matchListFilter = UNSET;
/**
* {@inheritDoc}
......@@ -545,6 +545,34 @@ public class RegressionParameters
private static KeywordsTestFilter UNSET_KEYWORDS_FILTER = new KeywordsTestFilter(UNSET);
@Override
public TestFilter getPriorStatusFilter() {
if (priorStatusFilter == UNSET) {
final TestFilter psf = super.getPriorStatusFilter();
if (psf == null) {
priorStatusFilter = null;
} else {
priorStatusFilter = new CachingTestFilter(
"jtregPriorStatusFilter",
"Select tests which match a specified status",
"Test did not match a specified status") {
@Override
protected String getCacheKey(TestDescription td) {
return td.getRootRelativeURL();
}
@Override
public boolean getCacheableValue(TestDescription td) throws Fault {
return psf.accepts(td);
}
};
}
}
return priorStatusFilter;
}
private CachingTestFilter priorStatusFilter = UNSET;
//---------------------------------------------------------------------
// The following (load and save) are an interim consequence of not using proper
......
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -200,26 +200,34 @@ public class RegressionTestFinder extends TagTestFinder
}
try {
cs.init(new BufferedReader(new FileReader(file)));
LineCounterBufferedReader r = new LineCounterBufferedReader(new FileReader(file));
cs.init(r);
if (super_fastScan)
cs.setFastScan(true);
String comment = cs.readComment();
int commentLine = r.lineNumber;
while (comment != null) {
@SuppressWarnings({"unchecked", "cast"}) // temporary, to cover transition generifying TestFinder
Map<String,String> tagValues = (Map<String,String>) parseComment(comment, file);
// Look ahead to see if there are more comments
comment = cs.readComment();
if (tagValues.isEmpty())
continue;
String nextComment = cs.readComment();
int nextCommentLine = r.lineNumber;
if (!tagValues.isEmpty()) {
if (tagValues.get("id") == null) {
// if there are more comments to come, or if there have already
// been additional comments, set an explicit id for each set of tags
if ((comment != null && comment.trim().startsWith("@test")) || testDescNumber != 0)
tagValues.put("id", "id" + (new Integer(testDescNumber)).toString());
if ((nextComment != null && nextComment.trim().startsWith("@test")) || testDescNumber != 0) {
String test = tagValues.get("test");
Matcher m;
String id = (test != null
&& (m = Pattern.compile("id=(?<id>[A-Za-z0-9-_]+)\\b.*").matcher(test)).matches())
? m.group("id")
: "id" + testDescNumber;
tagValues.put("id", id);
}
testDescNumber++;
}
......@@ -230,7 +238,11 @@ public class RegressionTestFinder extends TagTestFinder
// still needs to evaluate to a valid test description.)
tagValues.remove("test");
foundTestDescription(tagValues, file, /*line*/0);
foundTestDescription(tagValues, file, commentLine);
}
comment = nextComment;
commentLine = nextCommentLine;
}
}
catch (FileNotFoundException e) {
......@@ -248,6 +260,43 @@ public class RegressionTestFinder extends TagTestFinder
}
}
private class LineCounterBufferedReader extends BufferedReader {
int lineNumber;
LineCounterBufferedReader(FileReader r) {
super(r);
lineNumber = 1;
}
@Override
public int read() throws IOException {
int ch = super.read();
checkNewline(ch);
return ch;
}
@Override
public String readLine() throws IOException {
String line = super.readLine();
lineNumber++;
return line;
}
@Override
public int read(char[] buf, int offset, int length) throws IOException {
int n = super.read(buf, offset, length);
for (int i = offset; i < offset + n; i++) {
checkNewline(buf[i]);
}
return n;
}
private void checkNewline(int ch) {
if (ch == '\n') {
lineNumber++;
}
}
}
protected void scanTestNGFile(File tngRoot, File file) throws TestSuite.Fault {
Map<String,String> tagValues;
if (isTestNGTest(file)) {
......@@ -771,7 +820,7 @@ public class RegressionTestFinder extends TagTestFinder
/**
* Verify that the provided set of keys are allowed for the current
* test-suite. The set of keys is stored in the system property
* <code>env.regtest.key</code>.
* {@code env.regtest.key}.
*
* @param tagValues The map of all of the current tag values.
* @param value The value of the entry currently being processed.
......
......@@ -280,7 +280,7 @@ public class TestProperties {
}
private int getInt(String propertyName, int defaultValue) {
String v = properties.getProperty("maxOutputSize");
String v = properties.getProperty(propertyName);
try {
if (v != null) {
return Integer.parseInt(v.trim());
......
#
# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......
/*
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -355,6 +355,12 @@ public class CompileAction extends Action {
status = jcod(jcodArgs);
if (status.isPassed() && runJavac) {
javacArgs = getJavacCommandArgs(javacArgs);
for (String arg: javacArgs) {
if (arg.startsWith("-J")) {
othervmOverrideReasons.add("JVM options specified for compiler");
break;
}
}
if (explicitAnnotationProcessingRequested(javacArgs)
&& !getExtraModuleConfigOptions(Modules.Phase.DYNAMIC).isEmpty()) {
othervmOverrideReasons.add("additional runtime exports needed for annotation processing");
......@@ -554,9 +560,14 @@ public class CompileAction extends Action {
File argFile = getArgFile();
try (BufferedWriter w = new BufferedWriter(new FileWriter(argFile))) {
for (String arg: javacArgs) {
if (arg.startsWith("-J")) {
// remove -J for now; it will be added back later
javacVMOpts.add(arg.substring(2));
} else {
w.write(arg);
w.newLine();
}
}
} catch (IOException e) {
return error(COMPILE_CANT_WRITE_ARGS);
} catch (SecurityException e) {
......
......@@ -299,8 +299,10 @@ public class RegressionScript extends Script {
}
if (errmsg != null) {
msgPW.println(errmsg);
msgPW.println("Test result (overridden): " + status);
status = error("failed to clean up files after test");
msgPW.println("WARNING: failed to clean up files after test");
if (!agents.isEmpty()) {
msgPW.println("WARNING: closing agent(s)");
}
closeAgents();
}
}
......@@ -379,6 +381,7 @@ public class RegressionScript extends Script {
populateActionTable();
Expr.Context exprContext = params.getExprContext();
Map<String,String> testProps = getTestProperties();
for (String runCmd : runCmds) {
// e.g. reason compile/fail/ref=Foo.ref -debug Foo.java
// where "reason" indicates why the action should run
......@@ -406,7 +409,7 @@ public class RegressionScript extends Script {
continue;
}
Action action = (Action) (c.getDeclaredConstructor().newInstance());
action.init(opts, processArgs(args, exprContext), getReason(tokens), this);
action.init(opts, processArgs(args, exprContext, testProps), getReason(tokens), this);
actionList.add(action);
} catch (IllegalAccessException e) {
if (stopOnError)
......@@ -421,7 +424,8 @@ public class RegressionScript extends Script {
}
private List<String> processArgs(List<String> args, Expr.Context c) throws TestSuite.Fault, Expr.Fault {
private List<String> processArgs(List<String> args, Expr.Context c, Map<String,String> testProps)
throws TestSuite.Fault, Expr.Fault, ParseException {
if (!testSuite.getAllowSmartActionArgs(td))
return args;
......@@ -434,21 +438,27 @@ public class RegressionScript extends Script {
}
List<String> newArgs = new ArrayList<>();
for (String arg : args) {
newArgs.add(evalNames(arg, c));
newArgs.add(evalNames(arg, c, testProps));
}
return newArgs;
}
private static final Pattern namePattern = Pattern.compile("\\$\\{([A-Za-z0-9._]+)\\}");
private static String evalNames(String arg, Expr.Context c) throws Expr.Fault {
private static String evalNames(String arg, Expr.Context c, Map<String,String> testProps)
throws Expr.Fault, ParseException {
Matcher m = namePattern.matcher(arg);
StringBuffer sb = null;
while (m.find()) {
if (sb == null) {
sb = new StringBuffer();
}
m.appendReplacement(sb, c.get(m.group(1)));
String name = m.group(1);
String value = testProps.containsKey(name) ? testProps.get(name) : c.get(name);
if ("null".equals(value)) {
throw new ParseException("unset property " + name);
}
m.appendReplacement(sb, value);
}
if (sb == null) {
return arg;
......@@ -1077,7 +1087,7 @@ public class RegressionScript extends Script {
// Get the standard properties to be set for tests
Map<String, String> getTestProperties() throws TestClassException {
Map<String, String> getTestProperties() {
Map<String, String> p = new LinkedHashMap<>();
// The following will be added to javac.class.path on the test JVM
switch (getExecMode()) {
......
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -230,19 +230,19 @@ abstract class ScratchDirectory {
return ok;
}
boolean delete(File f, Set<File> cantDelete, PrintWriter log) {
if (f.delete()) {
private boolean delete(File f, Set<File> cantDelete, PrintWriter log) {
// optimistically assume the enclosing directory is writable
if (f.delete() && !f.exists()) {
cantDelete.remove(f);
return true;
} else {
// // See CODETOOLS-7901369
// // The following needs JDK 1.6, and/or convert jtreg to use nio.file.Path
// if (!f.canWrite()) {
// if (f.setWritable(true) && f.delete()) {
// cantDelete.remove(f);
// return true;
// }
// }
}
// retry if the enclosing directory was not writable and can be made writable
File dir = f.getParentFile();
if (dir != null && !dir.canWrite() && setWritable(dir, log)) {
return delete(f, cantDelete, log);
}
if (verboseScratchDir) {
log.println("warning: failed to delete "
+ (f.isDirectory() ? "directory " : "")
......@@ -251,6 +251,23 @@ abstract class ScratchDirectory {
cantDelete.add(f);
return false;
}
private boolean setWritable(File dir, PrintWriter log) {
// optimistically assume the enclosing directory is writable
if (dir.setWritable(true)) {
return true;
}
// retry if the enclosing directory was not writable and can be made writable
File parent = dir.getParentFile();
if (parent != null && !parent.canWrite() && setWritable(parent, log)) {
return setWritable(dir, log);
}
if (verboseScratchDir) {
log.println("warning: failed to set directory writable: " + dir);
}
return false;
}
// </editor-fold>
......
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -42,12 +42,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.sun.javatest.CompositeFilter;
import com.sun.javatest.TestFilter;
import com.sun.javatest.regtest.Main.Fault;
import com.sun.javatest.regtest.config.RegressionParameters;
import com.sun.javatest.regtest.config.RegressionTestSuite;
import com.sun.javatest.regtest.config.TestManager;
import com.sun.javatest.regtest.Main.Fault;
import com.sun.javatest.report.Report;
import com.sun.javatest.report.ReportSettings;
import com.sun.javatest.util.HTMLWriter;
/**
......@@ -61,8 +62,8 @@ public class RegressionReporter {
this.log = log;
}
@SuppressWarnings("deprecation")
public void report(RegressionParameters params, ElapsedTimeHandler elapsedTimeHandler, TestStats testStats, boolean quiet) {
public void report(RegressionParameters params, ElapsedTimeHandler elapsedTimeHandler,
TestStats testStats, TestFilter filter, boolean quiet) {
File rd = params.getReportDir();
File wd = params.getWorkDirectory().getRoot();
......@@ -76,10 +77,11 @@ public class RegressionReporter {
}
Report r = new Report();
Report.Settings s = new Report.Settings(params);
ReportSettings s = new ReportSettings(params);
if (reportKinds.contains("html")) {
s.setEnableHtmlReport(true);
s.setHtmlMainReport(true, true);
s.setShowKflReport(false);
}
if (reportKinds.contains("text")) {
s.setEnablePlainReport(true);
......@@ -87,7 +89,7 @@ public class RegressionReporter {
if (reportKinds.contains("xml")) {
s.setEnableXmlReport(true);
}
s.setFilter(new CompositeFilter(params.getFilters()));
s.setFilter(filter);
if (backups == null)
s.setEnableBackups(false);
else {
......@@ -99,7 +101,7 @@ public class RegressionReporter {
}
}
rd.mkdirs();
r.writeReport(s, rd);
r.writeReports(s, rd);
if (s.isPlainEnabled()) {
if (elapsedTimeHandler != null)
elapsedTimeHandler.report(r);
......
......@@ -100,6 +100,11 @@ public class JarFinder {
String ssp = uri.getRawSchemeSpecificPart();
int sep = ssp.lastIndexOf("!");
uri = new URI(ssp.substring(0, sep));
} else if (uri.getScheme().equals("file")) {
// not a jar, try the root path of class files
String ssp = uri.getRawSchemeSpecificPart();
int sep = ssp.indexOf(resName);
uri = new URI("file://" + ssp.substring(0, sep));
}
if (uri.getScheme().equals("file"))
result.append(new File(uri.getPath()));
......
......@@ -53,6 +53,7 @@ import java.util.Date;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
......@@ -62,12 +63,15 @@ import java.util.regex.Pattern;
import javax.swing.Timer;
import com.sun.interview.Interview;
import com.sun.javatest.AllTestsFilter;
import com.sun.javatest.Harness;
import com.sun.javatest.InterviewParameters;
import com.sun.javatest.JavaTestSecurityManager;
import com.sun.javatest.Keywords;
import com.sun.javatest.ParameterFilter;
import com.sun.javatest.ProductInfo;
import com.sun.javatest.Status;
import com.sun.javatest.StatusFilter;
import com.sun.javatest.TestEnvironment;
import com.sun.javatest.TestFilter;
import com.sun.javatest.TestFinder;
......@@ -323,18 +327,47 @@ public class Tool {
new Option(NONE, MAIN, "ro-nr", "-nr", "-noreport") {
@Override
public void process(String opt, String arg) {
noReportFlag = true;
reportMode = ReportMode.NONE;
}
},
new Option(STD, MAIN, "ro-nr", "-show") {
@Override
public void process(String opt, String arg) {
noReportFlag = true;
reportMode = ReportMode.NONE;
showStream = arg;
}
},
new Option(STD, MAIN, "ro-nr", "-report") {
@Override
public String[] getChoices() {
String[] values = new String[ReportMode.values().length];
int i = 0;
for (ReportMode m: ReportMode.values())
values[i++] = m.toString().toLowerCase(Locale.US).replace("_", "-");
return values;
}
@Override
public void process(String opt, String arg) throws BadArgs {
switch (arg) {
case "none":
reportMode = ReportMode.NONE;
break;
case "executed":
reportMode = ReportMode.EXECUTED;
break;
case "all-executed":
reportMode = ReportMode.ALL_EXECUTED;
break;
case "all":
reportMode = ReportMode.ALL;
break;
}
}
},
new Option(STD, TIMEOUT, "", "-timeout", "-timeoutFactor") {
@Override
public void process(String opt, String arg) throws BadArgs {
......@@ -1121,11 +1154,15 @@ public class Tool {
envVarArgs.add("CPAPPEND=" + filesToAbsolutePath(classPathAppendArg));
}
if (reportMode == null) {
reportMode = ReportMode.ALL_EXECUTED;
}
if (workDirArg == null) {
workDirArg = new File("JTwork");
}
if (reportDirArg == null && !noReportFlag) {
if (reportDirArg == null && reportMode != ReportMode.NONE) {
reportDirArg = new File("JTreport");
}
......@@ -1159,7 +1196,7 @@ public class Tool {
makeDir(new File(workDirArg, "scratch"), true);
if (!noReportFlag) {
if (reportMode != ReportMode.NONE) {
makeDir(reportDirArg, false);
testManager.setReportDirectory(reportDirArg);
......@@ -1288,7 +1325,7 @@ public class Tool {
out.println("Overall summary:");
}
testStats.showResultStats(out);
if (!noReportFlag) {
if (reportMode != ReportMode.NONE) {
RegressionReporter r = new RegressionReporter(out);
r.report(testManager);
}
......@@ -1798,7 +1835,7 @@ public class Tool {
private TestStats batchHarness(RegressionParameters params, boolean quiet)
throws Fault, Harness.Fault, InterruptedException {
boolean reportRequired =
!noReportFlag && !Boolean.getBoolean("javatest.noReportRequired");
reportMode != ReportMode.NONE && !Boolean.getBoolean("javatest.noReportRequired");
try {
TestStats stats = new TestStats();
......@@ -1913,7 +1950,39 @@ public class Tool {
if (reportRequired) {
RegressionReporter r = new RegressionReporter(out);
r.report(params, elapsedTimeHandler, stats, quiet);
TestFilter tf;
if (reportOnlyFlag) {
ParameterFilter pf = new ParameterFilter();
pf.update(params);
tf = pf;
} else {
switch (reportMode) {
case NONE:
default:
throw new IllegalStateException();
case EXECUTED:
ParameterFilter pf = new ParameterFilter();
pf.update(params);
tf = pf;
break;
case ALL_EXECUTED:
boolean[] statusValues = new boolean[Status.NUM_STATES];
statusValues[Status.PASSED] = true;
statusValues[Status.FAILED] = true;
statusValues[Status.ERROR] = true;
statusValues[Status.NOT_RUN] = false;
tf = new StatusFilter(statusValues, params.getWorkDirectory().getTestResultTable());
break;
case ALL:
tf = new AllTestsFilter();
break;
}
}
r.report(params, elapsedTimeHandler, stats, tf, quiet);
}
if (!reportOnlyFlag && !quiet)
......@@ -2083,7 +2152,7 @@ public class Tool {
addEnvVars(envVars, "PATH"); // accept user's path, for now
} else {
addEnvVars(envVars, DEFAULT_UNIX_ENV_VARS);
addEnvVars(envVars, "PATH=/bin:/usr/bin");
addEnvVars(envVars, "PATH=/bin:/usr/bin:/usr/sbin");
}
addEnvVars(envVars, envVarArgs);
for (Map.Entry<String, String> e: System.getenv().entrySet()) {
......@@ -2220,8 +2289,9 @@ public class Tool {
private JDK testJDK;
private boolean guiFlag;
private boolean reportOnlyFlag;
private boolean noReportFlag;
private String showStream;
public enum ReportMode { NONE, EXECUTED, ALL_EXECUTED, ALL };
private ReportMode reportMode;
private boolean allowSetSecurityManagerFlag = true;
private static Verbose verbose;
private boolean httpdFlag;
......
......@@ -230,12 +230,21 @@ help.main.ro.desc=Generate report for previously executed tests. This does not
tests must be provided. The default location is "./JTwork". To specify an \
alternate directory, use -workDir.
help.main.nr.desc=Do not generate a final report.
help.main.report.desc=Configure the report generated after tests are run.
help.main.report.arg=<value>
help.main.report.none.desc=Do not generate a report; equivalent to -noreport.
help.main.report.executed.desc=Include tests executed in the latest run
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 or not they have been executed
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 \
in a test suite, specify the name of the test suite.
help.main.show.desc=Show selected information from the results file for a test
help.main.show.arg=Name of information in the results file, such as "rerun".
help.main.show.desc=Show information from a section in the results file for a test. \
For example, -show:rerun
help.main.show.arg=<section-name>
help.main.w.desc=Location for .class files, .jtr files, etc. "./JTwork" is default
help.main.w.arg=<directory>
......