changeset 32:7caa97f6f7b6

jtreg bug fixes; passes self-test cleanly
author jrose
date Wed, 14 Oct 2009 18:06:15 -0700
parents 912e00503502
children d02552d5c1bd
files jtreg/jtreg-no-junit.zip jtreg/junitsupport.patch
diffstat 2 files changed, 106 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
Binary file jtreg/jtreg-no-junit.zip has changed
--- a/jtreg/junitsupport.patch	Mon Oct 12 16:30:53 2009 -0700
+++ b/jtreg/junitsupport.patch	Wed Oct 14 18:06:15 2009 -0700
@@ -1,3 +1,5 @@
+6891715: jtreg should be able to run tests in JUnit format
+
 diff --git a/.hgignore b/.hgignore
 --- a/.hgignore
 +++ b/.hgignore
@@ -7,11 +9,10 @@
 \ No newline at end of file
 +nbproject/private/
 +^make/faq.*html
-\ No newline at end of file
 diff --git a/make/Defs.gmk b/make/Defs.gmk
 --- a/make/Defs.gmk
 +++ b/make/Defs.gmk
-@@ -82,6 +82,12 @@
+@@ -84,6 +84,12 @@
  
  JAVATEST_JAR = $(JAVATEST_HOME)/lib/javatest.jar
  
@@ -84,7 +85,7 @@
      </target>
      
      <target name="-dist-jtreg.bin" depends="jar-jtreg,-dist-jtreg.doc">
-@@ -134,7 +140,7 @@
+@@ -138,7 +144,7 @@
              <manifest>
                  <attribute name="Built-By" value="${user.name}"/>
                  <attribute name="Main-Class" value="com.sun.javatest.regtest.Main"/>
@@ -93,25 +94,25 @@
                  <attribute name="jtreg-Name" value="jtreg"/>
                  <attribute name="jtreg-Version" value="${build.version}"/>
                  <attribute name="jtreg-Milestone" value="${build.milestone}"/>
-@@ -166,7 +172,7 @@
+@@ -170,7 +176,7 @@
              debug="true" debuglevel="source,lines" 
              srcdir="${src.classes.dir}" 
              destdir="${build.classes.dir}"
 -            classpath="${build.classes.dir}:${javatest.jar}">
 +            classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}">
              <patternset refid="jtreg.jdk11.files"/>
-             <compilerarg line="-Xlint:deprecation -Werror"/>
+             <compilerarg line="-Xlint:deprecation"/>
          </javac>
-@@ -174,7 +180,7 @@
+@@ -178,7 +184,7 @@
              debug="true" debuglevel="source,lines" 
              srcdir="${src.classes.dir}" 
              destdir="${build.classes.dir}"
 -            classpath="${build.classes.dir}:${javatest.jar}">
 +            classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}">
-             <compilerarg line="-Xlint:all -Werror"/>
+             <compilerarg line="-Xlint:all"/>
              <patternset refid="jtreg.packages"/>
          </javac>
-@@ -247,7 +253,7 @@
+@@ -251,7 +257,7 @@
          <!-- have to set fork=true because otherwise output redirection gets screwed up -->
          <mkdir dir="${build.dir}/jtreg"/>
          <java fork="true" failonerror="true"
@@ -120,7 +121,7 @@
              output="${build.dir}/jtreg/usage.txt">
              <jvmarg value="-Dprogram=jtreg"/>
              <arg value="-help"/>
-@@ -274,6 +280,10 @@
+@@ -278,6 +284,10 @@
          <copy file="${javatest.jar}" tofile="${dist.jtreg.dir}/lib/javatest.jar"/>
      </target>
  
@@ -131,7 +132,7 @@
      <target name="import-jtharness" depends="-init,import-javahelp" if="jtharness.ok">
          <copy todir="${dist.jtreg.dir}/legal/jtharness" file="${javatest.home}/legal/copyright.txt"/>
          <copy todir="${dist.jtreg.dir}/legal/jtharness" file="${javatest.home}/legal/license.txt"/>
-@@ -329,7 +339,7 @@
+@@ -333,7 +343,7 @@
   
      <target name="-test-jtreg.i18n" depends="compile-jtreg,-ant-jct.utils">
          <!-- have to set fork=true because otherwise output redirection gets screwed up -->
@@ -151,7 +152,7 @@
  	Main.java \
  	MainAction.java \
  	Option.java \
-@@ -71,14 +72,14 @@
+@@ -71,21 +72,21 @@
  		$(JAVAFILES.com.sun.javatest.regtest-jdk11:%=$(JAVADIR)/com/sun/javatest/regtest/%) \
  		$(JAVATEST_JAR) \
  		$(CLASSDIR)
@@ -168,6 +169,44 @@
  		$(J2SEJAVAC) -target $(J2SEJAVAC_TARGET) -encoding ISO8859-1 -d $(CLASSDIR) $(JAVAFILES.com.sun.javatest.regtest-j2se:%=$(JAVADIR)/com/sun/javatest/regtest/%)
  	echo "classes built at `date`" > $@
  
+ TARGETS.com.sun.javatest.regtest += $(BUILDDIR)/classes.com.sun.javatest.regtest.ok
+ 
+ $(JTREG_IMAGEDIR)/lib/jtreg.jar: JAR_MAINCLASS = com.sun.javatest.regtest.Main
+-$(JTREG_IMAGEDIR)/lib/jtreg.jar: JAR_CLASSPATH = javatest.jar jh.jar
++$(JTREG_IMAGEDIR)/lib/jtreg.jar: JAR_CLASSPATH = javatest.jar jh.jar junit.jar
+ 
+ #----------------------------------------------------------------------
+ #
+@@ -268,6 +269,11 @@
+ 
+ #----------------------------------------------------------------------
+ 
++# on some platforms the launcher inserts extra environment variables:
++T6517916-ENVIRONMENT-NORMALIZATIONS = \
++	-e 's|^JAVA_MAIN_CLASS[_0-9]*=|JAVA_MAIN_CLASS=|' \
++	-e '/^JAVA_MAIN_CLASS=/s|MainWrapper|Main|'
++
+ $(BUILDDIR)/T6517916.ok: \
+ 		$(TESTDIR)/javatest/regtest/6517916/T6517916.java \
+ 		$(JTREG_IMAGEDIR)/lib/javatest.jar \
+@@ -287,11 +293,16 @@
+ 		-svm \
+ 		$(TESTDIR)/javatest/regtest/6517916
+ 	$(SED) -e 's|:[^:]*ovm/classes:|:|' -e 's|:[^:]*/6517916:|:|' \
++		$(T6517916-ENVIRONMENT-NORMALIZATIONS) \
+ 		< $(@:%.ok=%)/work/ovm/scratch/T6517916.out \
+ 		> $(@:%.ok=%)/work/ovm/scratch/T6517916.out2
++	$(SED) \
++		$(T6517916-ENVIRONMENT-NORMALIZATIONS) \
++		< $(@:%.ok=%)/work/svm/scratch/T6517916.out \
++		> $(@:%.ok=%)/work/svm/scratch/T6517916.out2
+ 	$(DIFF) \
+ 		$(@:%.ok=%)/work/ovm/scratch/T6517916.out2 \
+-		$(@:%.ok=%)/work/svm/scratch/T6517916.out 
++		$(@:%.ok=%)/work/svm/scratch/T6517916.out2
+ 	echo "test passed at `date`" > $@
+ 
+ TESTS.com.sun.javatest.regtest += $(BUILDDIR)/T6517916.ok
 diff --git a/make/export.gmk b/make/export.gmk
 --- a/make/export.gmk
 +++ b/make/export.gmk
@@ -306,20 +345,6 @@
                  <source-level>1.5</source-level>
              </compilation-unit>
          </java-data>
-diff --git a/src/share/classes/com/sun/javatest/diff/i18n.properties b/src/share/classes/com/sun/javatest/diff/i18n.properties
---- a/src/share/classes/com/sun/javatest/diff/i18n.properties
-+++ b/src/share/classes/com/sun/javatest/diff/i18n.properties
-@@ -24,8 +24,8 @@
- #
- 
- help.cantFindReleaseNotes=
--help.cantFindSpec=
--help.cantReadSpec=
-+#help.cantFindSpec=
-+#help.cantReadSpec=
- help.onlineHelp.pleaseWait=
- help.releaseNotes=
- 
 diff --git a/src/share/classes/com/sun/javatest/regtest/Action.java b/src/share/classes/com/sun/javatest/regtest/Action.java
 --- a/src/share/classes/com/sun/javatest/regtest/Action.java
 +++ b/src/share/classes/com/sun/javatest/regtest/Action.java
@@ -330,7 +355,7 @@
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
-@@ -486,6 +486,11 @@
+@@ -511,6 +511,11 @@
          IGNORE_TEST_SUPPRESSED   = "@ignore suppressed by command line option",
          IGNORE_TEST_SUPPRESSED_C = "@ignore suppressed by command line option: ",
  
@@ -346,7 +371,7 @@
 new file mode 100644
 --- /dev/null
 +++ b/src/share/classes/com/sun/javatest/regtest/JUnitAction.java
-@@ -0,0 +1,138 @@
+@@ -0,0 +1,143 @@
 +/*
 + * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -443,7 +468,12 @@
 +            if (args.length != 1)
 +                throw new Error("wrong number of arguments");
 +            Class<?> mainClass = Class.forName(args[0]);
-+            org.junit.runner.Result result = org.junit.runner.JUnitCore.runClasses(mainClass);
++            org.junit.runner.Result result;
++            try {
++                result = org.junit.runner.JUnitCore.runClasses(mainClass);
++            } catch (NoClassDefFoundError ex) {
++                throw new Exception("Cannot load JUnit test harness", ex);
++            }
 +            if (!result.wasSuccessful()) {
 +                List<org.junit.runner.notification.Failure> failures = result.getFailures();
 +                for (Iterator<org.junit.runner.notification.Failure>
@@ -495,11 +525,24 @@
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
-@@ -1161,6 +1161,11 @@
+@@ -1174,11 +1174,27 @@
+         File jtreg_jar = findJar("jtreg.jar", "lib/jtreg.jar", getClass());
          if (jtreg_jar == null)
              throw new Fault(i18n, "main.cantFind.jtreg.jar");
-         
-+        File junit_jar = findJar("junit.jar", "lib/junit.jar", getClass());
++        
++        File junit_jar = null;
++        try {
++            junit_jar = findJar("junit.jar", "lib/junit.jar", org.junit.runner.JUnitCore.class);
++        } catch (NoClassDefFoundError ex) {
++        }
++        if (junit_jar == null) {
++            // Leave a place-holder.
++            String p = jtreg_jar.getPath();
++            int i = p.lastIndexOf("jtreg.jar");
++            if (i + "jtreg.jar".length() == p.length())
++                junit_jar = new File(p.substring(0, i) + "junit.jar");
++        }
+ 
 +        // Optional jar:
 +        //if (junit_jar == null)
 +        //    throw new Fault(...);
@@ -507,7 +550,11 @@
          File childJDKHome = jdk.getAbsoluteFile();
          File childJava = new File(new File(childJDKHome, "bin"), "java");
          File childTools  = new File(new File(childJDKHome, "lib"), "tools.jar");
-@@ -1173,6 +1178,7 @@
+-
+         File scratchDir = canon(new File(workDirArg, "scratch"));
+ 
+         List<String> c = new ArrayList<String>();
+@@ -1187,6 +1203,7 @@
          c.add("-classpath");
          List<File> classpath = new ArrayList<File>();
          classpath.add(jtreg_jar);
@@ -515,13 +562,13 @@
          classpath.add(childTools);
          classpath.addAll(classPathAppendArg);
          c.add(filesToAbsolutePath(classpath));
-@@ -1231,6 +1237,7 @@
+@@ -1245,6 +1262,7 @@
                  // Note the CLASSPATH will not be exactly the same as for otherVM tests,
                  // because it will not have (and cannot have) the test-specific values.
                  String cp = "CLASSPATH=" + javatest_jar + PATHSEP + jtreg_jar
 +                        + (junit_jar == null ? "" : PATHSEP + junit_jar)
                          + PATHSEP + jdk.getToolsJar();
-                 
+ 
                  String[] env = getEnvVars();
 diff --git a/src/share/classes/com/sun/javatest/regtest/MainAction.java b/src/share/classes/com/sun/javatest/regtest/MainAction.java
 --- a/src/share/classes/com/sun/javatest/regtest/MainAction.java
@@ -533,7 +580,7 @@
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
-@@ -76,6 +76,19 @@
+@@ -75,6 +75,19 @@
                       RegressionScript script)
          throws ParseException
      {
@@ -553,7 +600,7 @@
          this.script = script;
          this.reason = reason;
  
-@@ -120,6 +133,10 @@
+@@ -119,6 +132,10 @@
              timeout = 0;
          }
  
@@ -565,10 +612,9 @@
          // classname and the parameters to the named class
          for (int i = 0; i < args.length; i++) {
 @@ -151,6 +168,16 @@
-                 throw new ParseException(PARSE_SECURE_OTHERVM);
          }
      } // init()
-+
+ 
 +    public String getJavaArgs() {
 +        return javaArgs;
 +    }
@@ -578,10 +624,11 @@
 +    public String getMainClassName() {
 +        return buildFN;
 +    }
-     
++    
      @Override
      public File[] getSourceFiles() {
-@@ -221,6 +248,16 @@
+         List<File> l = new ArrayList<File>();
+@@ -220,6 +247,16 @@
      //----------internal methods------------------------------------------------
  
      private Status runOtherJVM() throws TestRunException {
@@ -598,7 +645,7 @@
  
          // WRITE ARGUMENT FILE
          String mainArgFileName = script.absTestClsDir() + FILESEP + buildFN
-@@ -228,8 +265,8 @@
+@@ -227,8 +264,8 @@
          FileWriter fw;
          try {
              fw = new FileWriter(mainArgFileName);
@@ -609,7 +656,7 @@
              fw.close();
          } catch (IOException e) {
              return Status.error(MAIN_CANT_WRITE_ARGS);
-@@ -288,7 +325,7 @@
+@@ -287,7 +324,7 @@
          command.add("com.sun.javatest.regtest.MainWrapper");
          command.add(mainArgFileName);
  
@@ -618,10 +665,11 @@
          for (int i = 0; i < mArgs.length; i++)
              command.add(mArgs[i]);
  
-@@ -391,6 +428,16 @@
+@@ -394,6 +431,16 @@
+                 //return Status.error(MAIN_SECMGR_BAD);
              }
          }
-         
++        
 +        String mainClass = buildFN;
 +        String stringifiedArgs = (mainArgs == null ? "" : mainArgs);
 +        if (driverFN != null) {
@@ -631,11 +679,10 @@
 +                stringifiedArgs = mainClass + " " + stringifiedArgs;
 +            mainClass = driverFN;
 +        }
-+
+ 
          ByteArrayOutputStream newOut = new ByteArrayOutputStream();
          ByteArrayOutputStream newErr = new ByteArrayOutputStream();
-         PrintStream psOut = new PrintStream(newOut);
-@@ -413,13 +460,19 @@
+@@ -417,15 +464,21 @@
                      }
                  }
              }
@@ -651,14 +698,18 @@
 +
              Class<?>[] argTypes = { String[].class };
              Method method = c.getMethod("main", argTypes);
-             
+-
++            
              // XXX 4/1 possible to use splitSeparator instead?
 -            String[] tmpArgs = StringArray.splitWS(mainArgs);
 +            String[] tmpArgs = StringArray.splitWS(stringifiedArgs);
              Object[] runArgs = {tmpArgs};
-             
+-
++            
              Status stat = redirectOutput(psOut, psErr);
-@@ -485,14 +538,14 @@
+             if (!stat.isPassed()) {
+                 return stat;
+@@ -489,14 +542,14 @@
              e.printStackTrace(new PrintWriter(psErr, true));
              psErr.println();
              psErr.println("JavaTest Message: main() method must be in a public class named");
@@ -675,7 +726,7 @@
              psErr.println();
              status = Status.error(MAIN_CANT_FIND_MAIN);
          } finally {
-@@ -701,6 +754,7 @@
+@@ -697,6 +750,7 @@
  
      private String  javaArgs = "";
      private String  mainArgs = "";
@@ -721,7 +772,7 @@
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
-@@ -399,6 +399,7 @@
+@@ -414,6 +414,7 @@
          addAction("compile", CompileAction.class);
          addAction("ignore", IgnoreAction.class);
          addAction("main", MainAction.class);
@@ -729,7 +780,7 @@
          addAction("shell", ShellAction.class);
      } // populateActionTable()
  
-@@ -744,7 +745,22 @@
+@@ -759,7 +760,22 @@
              System.arraycopy(cacheAbsSrcLibList, 0, cacheJavaSrcPath, 1,
                               cacheAbsSrcLibList.length);
          }
@@ -814,8 +865,8 @@
          numIgnore += 2;
  
 +        // junit
-+        numPassed += 5; numFailed += 6; numError  += 8 + 8 /*Pass/Fail, badarg*/;
-+        numJUnit  += 27;
++        numPassed += 6; numFailed += 6; numError  += 8 + 8 /*Pass/Fail, badarg*/;
++        numJUnit  += 28;
 +
          // main
          numPassed += 12; numFailed += 19; numError  += 12;