forked from openjdk/jtreg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
7903760: Revert "7903622: Remove support for
jtdiff
"
Reviewed-by: jjg
- Loading branch information
Showing
22 changed files
with
3,322 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Copyright (c) 1999, 2016, 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 | ||
# under the terms of the GNU General Public License version 2 only, as | ||
# published by the Free Software Foundation. Oracle designates this | ||
# particular file as subject to the "Classpath" exception as provided | ||
# by Oracle in the LICENSE file that accompanied this code. | ||
# | ||
# This code is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# version 2 for more details (a copy is included in the LICENSE file that | ||
# accompanied this code). | ||
# | ||
# You should have received a copy of the GNU General Public License version | ||
# 2 along with this work; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
# or visit www.oracle.com if you need additional information or have any | ||
# questions. | ||
# | ||
|
||
#---------------------------------------------------------------------- | ||
# | ||
# compile com.sun.javatest.diff | ||
|
||
JAVAFILES.com.sun.javatest.diff := \ | ||
$(shell $(FIND) $(JAVADIR)/com/sun/javatest/diff -name \*.java ) | ||
|
||
$(BUILDDIR)/classes.com.sun.javatest.diff.ok: \ | ||
$(JAVAFILES.com.sun.javatest.diff) \ | ||
$(BUILDDIR)/classes.com.sun.javatest.regtest.ok | ||
CLASSPATH="$(CLASSDIR)$(PS)$(JAVATEST_JAR)$(PS)$(ANT_JAR)" \ | ||
$(REGTEST_TOOL_JAVAC) $(REGTEST_TOOL_JAVAC_OPTIONS) \ | ||
-d $(CLASSDIR) \ | ||
-encoding ASCII \ | ||
$(JAVAFILES.com.sun.javatest.diff) | ||
echo "classes built at `date`" > $@ | ||
|
||
TARGETS.com.sun.javatest.diff += $(BUILDDIR)/classes.com.sun.javatest.diff.ok | ||
|
||
#---------------------------------------------------------------------- | ||
# | ||
# resources required for com.sun.javatest.diff | ||
|
||
RESOURCES.com.sun.javatest.diff = \ | ||
$(CLASSDIR)/com/sun/javatest/diff/i18n.properties | ||
|
||
TARGETS.com.sun.javatest.diff += $(RESOURCES.com.sun.javatest.diff) | ||
|
||
#---------------------------------------------------------------------- | ||
# | ||
# include jtdiff in jtreg.jar | ||
|
||
PKGS.JAR.jtreg += com.sun.javatest.diff | ||
TARGETS.JAR.jtreg += $(TARGETS.com.sun.javatest.diff) | ||
|
||
#---------------------------------------------------------------------- | ||
# | ||
# executable scripts | ||
|
||
$(JTREG_IMAGEDIR)/bin/jtdiff: $(SRCSHAREBINDIR)/jtdiff.sh | ||
$(MKDIR) -p $(@D) | ||
$(RM) $@ | ||
$(CP) $< $@ | ||
$(CHMOD) a+x,a-w $@ | ||
|
||
TARGETS.ZIP.jtreg += \ | ||
$(JTREG_IMAGEDIR)/bin/jtdiff | ||
|
||
#---------------------------------------------------------------------- | ||
|
||
TESTS += $(TESTS.jtdiff) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 1998, 2015, 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 | ||
# under the terms of the GNU General Public License version 2 only, as | ||
# published by the Free Software Foundation. Oracle designates this | ||
# particular file as subject to the "Classpath" exception as provided | ||
# by Oracle in the LICENSE file that accompanied this code. | ||
# | ||
# This code is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# version 2 for more details (a copy is included in the LICENSE file that | ||
# accompanied this code). | ||
# | ||
# You should have received a copy of the GNU General Public License version | ||
# 2 along with this work; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
# or visit www.oracle.com if you need additional information or have any | ||
# questions. | ||
# | ||
|
||
# Usage: | ||
# jtdiff ...args.... | ||
# | ||
# jtdiff requires a version of Java equivalent to JDK 1.5.0 or higher. | ||
|
||
# $JT_HOME can be used to specify the jtdiff installation directory | ||
# (e.g. /usr/local/java/jct-tools/3.2.2) | ||
# | ||
# $JT_JAVA is used to specify the version of java to use when running JavaTest | ||
# (e.g. /usr/local/java/jdk1.5.0/solaris-sparc/bin/java) | ||
# | ||
# jtdiff also provides an Ant task for direct invocation from Ant. | ||
|
||
# Determine jtdiff/JavaTest installation directory | ||
if [ -n "$JT_HOME" ]; then | ||
if [ ! -r $JT_HOME/lib/jtreg.jar ];then | ||
echo "Invalid JT_HOME=$JT_HOME. Cannot find or read $JT_HOME/lib/jtreg.jar" | ||
exit 1; | ||
fi | ||
else | ||
# Deduce where script is installed | ||
# - should work on most derivatives of Bourne shell, like ash, bash, ksh, | ||
# sh, zsh, etc, including on Windows, MKS (ksh) and Cygwin (ash or bash) | ||
if type -p type 1>/dev/null 2>&1 && test -z "`type -p type`" ; then | ||
myname=`type -p "$0"` | ||
elif type type 1>/dev/null 2>&1 ; then | ||
myname=`type "$0" | sed -e 's/^.* is a tracked alias for //' -e 's/^.* is //'` | ||
elif whence whence 1>/dev/null 2>&1 ; then | ||
myname=`whence "$0"` | ||
fi | ||
mydir=`dirname "$myname"` | ||
p=`cd "$mydir" ; pwd` | ||
while [ -n "$p" -a "$p" != "/" ]; do | ||
if [ -r "$p"/lib/jtreg.jar ]; then JT_HOME="$p" ; break; fi | ||
p=`dirname "$p"` | ||
done | ||
if [ -z "$JT_HOME" ]; then | ||
echo "Cannot determine JT_HOME; please set it explicitly"; exit 1 | ||
fi | ||
fi | ||
|
||
# Normalize JT_HOME if using Cygwin | ||
case "`uname -s`" in | ||
CYGWIN* ) cygwin=1 ; JT_HOME=`cygpath -a -m "$JT_HOME"` ;; | ||
esac | ||
|
||
|
||
# Separate out -J* options for the JVM | ||
# Unset IFS and use newline as arg separator to preserve spaces in args | ||
DUALCASE=1 # for MKS: make case statement case-sensitive (6709498) | ||
saveIFS="$IFS" | ||
nl=' | ||
' | ||
for i in "$@" ; do | ||
IFS= | ||
if [ -n "$cygwin" ]; then i=`echo $i | sed -e 's|/cygdrive/\([A-Za-z]\)/|\1:/|'` ; fi | ||
case $i in | ||
-J* ) javaOpts=$javaOpts$nl`echo $i | sed -e 's/^-J//'` ;; | ||
* ) jtdiffOpts=$jtdiffOpts$nl$i ;; | ||
esac | ||
IFS="$saveIFS" | ||
done | ||
unset DUALCASE | ||
|
||
# Determine java for jtdiff, from JT_JAVA, JAVA_HOME, java | ||
if [ -n "$JT_JAVA" ]; then | ||
if [ -d "$JT_JAVA" ]; then | ||
JT_JAVA="$JT_JAVA/bin/java" | ||
fi | ||
elif [ -n "$JAVA_HOME" ]; then | ||
JT_JAVA="$JAVA_HOME/bin/java" | ||
else | ||
JT_JAVA=java | ||
fi | ||
|
||
# Verify java version (1.)5 or newer used to run jtdiff | ||
version=`"$JT_JAVA" -classpath "${JT_HOME}/lib/jtreg.jar" com.sun.javatest.regtest.agent.GetSystemProperty java.version 2>&1 | | ||
grep 'java.version=' | sed -e 's/^.*=//' -e 's/^1\.//' -e 's/\([1-9][0-9]*\).*/\1/'` | ||
|
||
if [ -z "$version" ]; then | ||
echo "Cannot determine version of java to run jtdiff" | ||
exit 1; | ||
elif [ "$version" -lt 5 ]; then | ||
echo "java version 5 or later is required to run jtdiff" | ||
exit 1; | ||
fi | ||
|
||
# And finally ... | ||
|
||
IFS=$nl | ||
|
||
"${JT_JAVA:-${JAVA_HOME:+$JAVA_HOME/bin/}java}" \ | ||
$javaOpts \ | ||
-Dprogram=`basename "$0"` \ | ||
-cp "${JT_HOME}/lib/jtreg.jar" \ | ||
com.sun.javatest.diff.Main \ | ||
$jtdiffOpts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* | ||
* Copyright (c) 2007, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
package com.sun.javatest.diff; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
import com.sun.javatest.Status; | ||
import com.sun.javatest.TestResult; | ||
import com.sun.javatest.TestSuite; | ||
import com.sun.javatest.WorkDirectory; | ||
import com.sun.javatest.util.I18NResourceBundle; | ||
|
||
public abstract class Diff { | ||
|
||
public abstract boolean report(File outFile) throws Fault, InterruptedException; | ||
|
||
protected boolean diff(List<File> files, File outFile) | ||
throws Fault, InterruptedException { | ||
this.outFile = outFile; | ||
List<DiffReader> list = new ArrayList<>(); | ||
for (File f: files) | ||
list.add(open(f)); | ||
|
||
PrintWriter prevOut = out; | ||
if (outFile != null) { | ||
try { | ||
out = new PrintWriter(new BufferedWriter(new FileWriter(outFile))); // FIXME don't want to use PrintWriter | ||
} catch (IOException e) { | ||
throw new Fault(i18n, "diff.cantOpenFile", outFile, e); | ||
} | ||
} | ||
|
||
try { | ||
initComparator(); | ||
|
||
initReporter(); | ||
reporter.setTitle(title); | ||
reporter.setComparator(comparator); | ||
reporter.setReaders(list); | ||
|
||
List<int[]> testCounts = new ArrayList<>(); | ||
MultiMap<String, TestResult> table = new MultiMap<>(); | ||
for (DiffReader r: list) { | ||
int index = table.addColumn(r.getFile().getPath()); | ||
int[] counts = new int[Status.NUM_STATES]; | ||
for (TestResult tr: r) { | ||
table.addRow(index, tr.getTestName(), tr); | ||
counts[tr.getStatus().getType()]++; | ||
} | ||
testCounts.add(counts); | ||
} | ||
reporter.setTestCounts(testCounts); | ||
|
||
try { | ||
reporter.write(table); | ||
} catch (IOException e) { | ||
throw new Fault(i18n, "diff.ioError", e); | ||
} | ||
|
||
return (reporter.diffs == 0); | ||
} finally { | ||
if (out != prevOut) { | ||
// try { | ||
out.close(); | ||
// } catch (IOException e) { | ||
// throw new Fault(i18n, "main.ioError", e); | ||
// } | ||
out = prevOut; | ||
} | ||
} | ||
} | ||
|
||
protected void initFormat() { | ||
if (format == null && outFile != null) { | ||
String name = outFile.getName(); | ||
int dot = name.lastIndexOf("."); | ||
if (dot != -1) | ||
format = name.substring(dot + 1).toLowerCase(); | ||
} | ||
} | ||
|
||
protected void initReporter() throws Fault { | ||
if (reporter == null) { | ||
try { | ||
initFormat(); | ||
if (format != null && format.equals("html")) | ||
reporter = new HTMLReporter(out); | ||
else | ||
reporter = new SimpleReporter(out); | ||
} catch (IOException e) { | ||
throw new Fault(i18n, "diff.cantOpenReport", e); | ||
} | ||
} | ||
} | ||
|
||
protected void initComparator() { | ||
if (comparator == null) | ||
comparator = new StatusComparator(includeReason); | ||
} | ||
|
||
protected DiffReader open(File f) throws Fault { | ||
if (!f.exists()) | ||
throw new Fault(i18n, "main.cantFindFile", f); | ||
|
||
try { | ||
if (WorkDirectoryReader.accepts(f)) | ||
return new WorkDirectoryReader(f); | ||
|
||
if (ReportReader.accepts(f)) | ||
return new ReportReader(f); | ||
|
||
throw new Fault(i18n, "main.unrecognizedFile", f); | ||
|
||
} catch (TestSuite.Fault | ||
| WorkDirectory.Fault | ||
| IOException e) { | ||
throw new Fault(i18n, "main.cantOpenFile", f, e); | ||
} | ||
|
||
} | ||
|
||
protected File outFile; | ||
protected PrintWriter out; | ||
protected Comparator<TestResult> comparator; | ||
protected Reporter reporter; | ||
protected boolean includeReason; | ||
protected String format; | ||
protected String title; | ||
private static final I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Diff.class); | ||
} |
Oops, something went wrong.