8020719: Run tests with reduced splitter threshold
authorhannesw
Fri, 26 Jul 2013 13:50:52 +0200
changeset 19103 3905e242e69c
parent 19101 3e6fe94f02a8
child 19104 6fe18e748f74
8020719: Run tests with reduced splitter threshold Reviewed-by: lagergren, sundar, jlaskey
nashorn/make/build.xml
nashorn/make/project.properties
nashorn/test/script/basic/NASHORN-592-dual.js
nashorn/test/script/basic/NASHORN-592-dual.js.EXPECTED
nashorn/test/script/basic/compile-octane-splitter.js
nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED
nashorn/test/script/basic/splitter.js
nashorn/test/script/basic/splitter.js.EXPECTED
nashorn/test/script/representations/NASHORN-592a.js
nashorn/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java
nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java
nashorn/test/src/jdk/nashorn/internal/test/framework/TestConfig.java
nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java
--- a/nashorn/make/build.xml	Thu Jul 25 20:10:48 2013 +0530
+++ b/nashorn/make/build.xml	Fri Jul 26 13:50:52 2013 +0200
@@ -47,10 +47,10 @@
     <!-- check if testng.jar is avaiable -->
     <available property="testng.available" file="${file.reference.testng.jar}"/>
 
-	<!-- enable/disable make code coverage -->
-	<condition property="cc.enabled">
-		<istrue value="${make.code.coverage}" />
-	</condition>
+    <!-- enable/disable make code coverage -->
+    <condition property="cc.enabled">
+        <istrue value="${make.code.coverage}" />
+    </condition>
 
     <!-- exclude tests in exclude lists -->
     <condition property="exclude.list" value="./exclude/exclude_list_cc.txt" else="./exclude/exclude_list.txt">
@@ -60,9 +60,9 @@
 
   <target name="init" depends="init-conditions, init-cc">
 
-	<!-- extends jvm args -->
-	<property name="run.test.jvmargs" value="${run.test.jvmargs.main}  ${run.test.cc.jvmargs}"/>
-	<property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main}  ${run.test.cc.jvmargs}" />
+    <!-- extends jvm args -->
+    <property name="run.test.jvmargs" value="${run.test.jvmargs.main}  ${run.test.cc.jvmargs}"/>
+    <property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main}  ${run.test.cc.jvmargs}" />
 
     <echo message="run.test.jvmargs=${run.test.jvmargs}"/>
     <echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
@@ -294,19 +294,6 @@
   </target>
 
   <target name="test" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
-    <java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output1.log" error="${build.dir}/err.log">
-      <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="-Dnashorn.fields.dual=true"/>
-      <arg value="NASHORN-592a.js"/>
-    </java>
-    <java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output2.log" error="${build.dir}/err.log">
-      <jvmarg line="${ext.class.path}"/>
-      <arg value="NASHORN-592a.js"/>
-    </java>
-    <condition property="representation-ok">
-      <filesmatch file1="${build.dir}/output1.log" file2="${build.dir}/output2.log"/>
-    </condition>
-    <fail unless="representation-ok">Representation test failed - output differs!</fail>
     <fileset id="test.classes" dir="${build.test.classes.dir}">
       <include name="**/api/javaaccess/*Test.class"/>
       <include name="**/api/scripting/*Test.class"/>
--- a/nashorn/make/project.properties	Thu Jul 25 20:10:48 2013 +0530
+++ b/nashorn/make/project.properties	Fri Jul 26 13:50:52 2013 +0200
@@ -223,7 +223,6 @@
 run.test.user.country=TR
 
 #  -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods
-# add '-Dtest.js.outofprocess' to run each test in a new sub-process
 run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -ea -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country}
 
 #-XX:+HeapDumpOnOutOfMemoryError -XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/NASHORN-592-dual.js	Fri Jul 26 13:50:52 2013 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2013, 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.
+ * 
+ * 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.
+ */
+
+/**
+ * NASHORN-592-dual: test all combos of field types and getters and setters
+ * This time use dual field representation
+ *
+ * @test
+ * @option -Dnashorn.fields.dual=true
+ * @fork
+ * @run/ignore-std-error
+ */
+
+load(__DIR__ + 'NASHORN-592.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/NASHORN-592-dual.js.EXPECTED	Fri Jul 26 13:50:52 2013 +0200
@@ -0,0 +1,44 @@
+0
+0
+NaN
+undefinedhej!
+17
+8
+34
+17hej!
+17
+8
+34.9422
+17.4711hej!
+0
+0
+NaN
+Fame and fortune Salamander Yahoo!hej!
+24
+11111
+23.23
+23
+23
+Have some pie!
+4711.17
+17172
+23
+23.23
+23
+23
+Have some pie!
+4711.17
+23
+111
+4711.16
+I like cake!
+0
+NaN
+0
+I like cake!
+17
+17.4711
+salamander
+4711.17
+axolotl
+lizard
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/compile-octane-splitter.js	Fri Jul 26 13:50:52 2013 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2013, 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.
+ * 
+ * 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.
+ */
+
+/**
+ * @test
+ * @option -Dnashorn.compiler.splitter.threshold=1000
+ * @fork
+ * @runif external.octane
+ */ 
+
+compile_only = true;
+load(__DIR__ + 'run-octane.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED	Fri Jul 26 13:50:52 2013 +0200
@@ -0,0 +1,13 @@
+Compiled OK: box2d
+Compiled OK: code-load
+Compiled OK: crypto
+Compiled OK: deltablue
+Compiled OK: earley-boyer
+Compiled OK: gbemu
+Compiled OK: mandreel
+Compiled OK: navier-stokes
+Compiled OK: pdfjs
+Compiled OK: raytrace
+Compiled OK: regexp
+Compiled OK: richards
+Compiled OK: splay
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/splitter.js	Fri Jul 26 13:50:52 2013 +0200
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2013, 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.
+ * 
+ * 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.
+ */
+
+/**
+ * Test various scripts with low splitter threshold
+ *
+ * @test
+ * @option -Dnashorn.compiler.splitter.threshold=200
+ * @run
+ * @fork
+ */
+
+load(__DIR__ + 'prototype.js');
+load(__DIR__ + 'yui.js');
+load(__DIR__ + 'NASHORN-689.js');
+load(__DIR__ + 'NASHORN-58.js');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/splitter.js.EXPECTED	Fri Jul 26 13:50:52 2013 +0200
@@ -0,0 +1,76 @@
+parsed and compiled ok prototype.js
+parsed and compiled ok yui-min.js
+parsed and compiled ok yui.js
+a=10
+a=9
+a=8
+a=7
+a=6
+a=5
+a=4
+a=3
+a=2
+a=1
+a=0
+10
+a=0
+a=1
+a=2
+a=3
+a=4
+a=5
+a=6
+a=7
+a=8
+a=9
+a=10
+ok
+a=0
+a=1
+a=2
+a=3
+a=4
+a=5
+a=6
+a=7
+a=8
+a=9
+a=10
+done
+no arg
+x=0
+x=1
+x=2
+x=3
+x=4
+x=5
+x=6
+x=7
+x=8
+x=9
+x=10
+ok
+done
+try
+finally
+3
+try
+finally
+2
+3
+1
+2
+3
+4
+5
+5
+6
+6
+1
+2
+3
+4
+6
+Error: testing
+finally
+SUCCESS
--- a/nashorn/test/script/representations/NASHORN-592a.js	Thu Jul 25 20:10:48 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, 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.
- * 
- * 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.
- */
-
-/**
- * NASHORN-592a: test all combos of field types and getters and setters
- * This time use dual field representation
- *
- * @test
- * @option --dual-fields
- * @run
- */
-
-//fortype undefined
-var a;
-
-print(a & 0xff);
-print(a >>> 1);
-print(a * 2);
-print(a + "hej!");
-
-var b;
-b = 17;   //set undefined->int
-
-print(b & 0xff);
-print(b >>> 1);
-print(b * 2);
-print(b + "hej!");
-
-var c;
-c = 17.4711 //set undefined->double
-
-print(c & 0xff);
-print(c >>> 1);
-print(c * 2);
-print(c + "hej!");
-
-var d; // set undefined->double
-d = "Fame and fortune Salamander Yahoo!";
-
-print(d & 0xff);
-print(d >>> 1);
-print(d * 2);
-print(d + "hej!");
-
-// now we have exhausted all getters and undefined->everything setters.
-
-
-var e = 23; // int to everything setters,
-e = 24;     //int to int
-print(e);
-e = (22222 >>> 1); //int to long;
-print(e);
-e = 23.23;  //int to double
-print(e);
-e = 23;     //double to int - still double
-print(e);
-print(e & 0xff);
-e = "Have some pie!" //double to string
-print(e);
-e = 4711.17;
-print(e); //still an object not a double
-
-
-var f = (23222 >>> 1); // long to everything setters,
-f = 34344 >>> 1;     //long to long
-print(f);
-f = 23; //long to int - still long
-print(f);
-f = 23.23;  //long to double
-print(f);
-f = 23;     //double to int - still double
-print(f);
-print(f & 0xff);
-f = "Have some pie!" //double to string
-print(f);
-f = 4711.17;
-print(f); //still an object not a double
-
-var g = 4811.16;
-g = 23; //still double
-print(g);
-g = (222 >>> 1); //still double
-print(g);
-g = 4711.16; //double->double
-print(g);
-g = "I like cake!";
-print(g);  //object to various
-print(g & 0xff);
-print(g * 2);
-print(g >>> 2);
-print(g);
-
-var h = {x:17, y:17.4711, z:"salamander"};
-print(h.x);
-print(h.y);
-print(h.z);
-h.x = 4711.17;
-h.y = "axolotl";
-h.z = "lizard";
-print(h.x);
-print(h.y);
-print(h.z);
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java	Thu Jul 25 20:10:48 2013 +0530
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java	Fri Jul 26 13:50:52 2013 +0200
@@ -29,6 +29,7 @@
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_COMPARE;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_COMPILE_FAIL;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_RUN_FAIL;
+import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_FORK;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_IGNORE_STD_ERROR;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_RUN;
 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_FAIL_LIST;
@@ -68,6 +69,8 @@
     protected final boolean checkCompilerMsg;
     // .EXPECTED file compared for this or test?
     protected final boolean compare;
+    // should test run in a separate process?
+    protected final boolean fork;
     // ignore stderr output?
     protected final boolean ignoreStdError;
     // Foo.js.OUTPUT file where test stdout messages go
@@ -98,6 +101,7 @@
         this.checkCompilerMsg = testOptions.containsKey(OPTIONS_CHECK_COMPILE_MSG);
         this.ignoreStdError = testOptions.containsKey(OPTIONS_IGNORE_STD_ERROR);
         this.compare = testOptions.containsKey(OPTIONS_COMPARE);
+        this.fork = testOptions.containsKey(OPTIONS_FORK);
 
         final String testName = testFile.getName();
         this.outputFileName = buildDir + File.separator + testName + ".OUTPUT";
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java	Thu Jul 25 20:10:48 2013 +0530
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java	Fri Jul 26 13:50:52 2013 +0200
@@ -43,6 +43,8 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+
+import jdk.nashorn.tools.Shell;
 import org.testng.Assert;
 import org.testng.ITest;
 import org.testng.annotations.Test;
@@ -53,9 +55,6 @@
  * corresponding .EXPECTED file.
  */
 public final class ScriptRunnable extends AbstractScriptRunnable implements ITest {
-    // when test is run in a separate process, this is the command line
-    protected final ArrayList<String> separateProcessArgs;
-
     public ScriptRunnable(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions,  final List<String> scriptArguments) {
         super(framework, testFile, engineOptions, testOptions, scriptArguments);
 
@@ -63,9 +62,6 @@
           // add --dump-on-error option always so that we can get detailed error msg.
           engineOptions.add("-doe");
         }
-
-        final String separateProcess = System.getProperty("test.js.separateprocess");
-        this.separateProcessArgs = separateProcess == null ? null : new ArrayList<>(Arrays.asList(separateProcess.split(" ")));
     }
 
     @Override
@@ -81,7 +77,7 @@
 
     @Override
     protected void execute() {
-        if (separateProcessArgs != null) {
+        if (fork) {
             executeInNewProcess();
         } else {
             executeInThisProcess();
@@ -172,15 +168,21 @@
     }
 
     private void executeInNewProcess() {
-        final List<String> args = separateProcessArgs;
+
+        final String separator = System.getProperty("file.separator");
+        final List<String> cmd = new ArrayList<>();
+
+        cmd.add(System.getProperty("java.home") + separator + "bin" + separator + "java");
+        cmd.add("-Djava.ext.dirs=dist");
+        cmd.add(Shell.class.getName());
         // now add the rest of the "in process" runtime arguments
-        args.addAll(getRuntimeArgs());
+        cmd.addAll(getRuntimeArgs());
 
         final File outputFileHandle = new File(outputFileName);
         final File errorFileHandle = new File(errorFileName);
 
         try {
-            final ProcessBuilder pb = new ProcessBuilder(args);
+            final ProcessBuilder pb = new ProcessBuilder(cmd);
             pb.redirectOutput(outputFileHandle);
             pb.redirectError(errorFileHandle);
             final Process process = pb.start();
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestConfig.java	Thu Jul 25 20:10:48 2013 +0530
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestConfig.java	Fri Jul 26 13:50:52 2013 +0200
@@ -36,6 +36,7 @@
     public static final String   OPTIONS_EXPECT_RUN_FAIL     = "expect-run-fail";
     public static final String   OPTIONS_IGNORE_STD_ERROR    = "ignore-std-error";
     public static final String   OPTIONS_COMPARE             = "compare";
+    public static final String   OPTIONS_FORK                = "fork";
 
     // System property names used for various test configurations
 
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Thu Jul 25 20:10:48 2013 +0530
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Fri Jul 26 13:50:52 2013 +0200
@@ -29,6 +29,7 @@
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_COMPARE;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_COMPILE_FAIL;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_RUN_FAIL;
+import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_FORK;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_IGNORE_STD_ERROR;
 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_RUN;
 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_FAILED_LIST_FILE;
@@ -208,6 +209,7 @@
         boolean checkCompilerMsg = false;
         boolean noCompare = false;
         boolean ignoreStdError = false;
+        boolean fork = false;
 
         final List<String> engineOptions = new ArrayList<>();
         final List<String> scriptArguments = new ArrayList<>();
@@ -284,6 +286,9 @@
                 case "@option":
                     engineOptions.add(scanner.next());
                     break;
+                case "@fork":
+                    fork = true;
+                    break;
                 }
 
                 // negative tests are expected to fail at runtime only
@@ -324,6 +329,9 @@
             if (ignoreStdError) {
                 testOptions.put(OPTIONS_IGNORE_STD_ERROR, "true");
             }
+            if (fork) {
+                testOptions.put(OPTIONS_FORK, "true");
+            }
 
             tests.add(factory.createTest(framework, testFile.toFile(), engineOptions, testOptions, scriptArguments));
         } else if (!isNotTest) {