< prev index next >

test/script/nosecurity/jjs-common.js

Print this page

        

@@ -24,19 +24,33 @@
 /**
  * JDK-8144113: Nashorn: enable jjs testing.
  * @subtest
  * @summary test used by all other jjs-option* test cases
  */
-var javaHome = $ENV.JAVA_HOME,

-    homeJjs = "${javaHome}/bin/jjs",

-    altJjs = $EXEC('which jjs').trim(),

-    homejavac = "${javaHome}/bin/javac",

-    altjavac = $EXEC('which javac').trim()

-

-var Files = Java.type('java.nio.file.Files'),

-    Paths = Java.type('java.nio.file.Paths'),

-    System = Java.type('java.lang.System')

+

+load(__DIR__ + "JDK-util.js")

+

+var javaHome = System.getenv("JAVA_HOME"),

+    homeJjs = "${javaHome}" + "/bin/jjs",

+    altJjs = which('jjs'),

+    homejavac = "${javaHome}" + "/bin/javac",

+    altjavac = which('javac')

+

+if (windows) {

+    if (winCyg) {

+        //Files.exists() expects proper extension as it talks to windows filesystem even on cygwin

+        //make paths work on on underlying shells cygwin/cmd/linux.

+        homeJjs = toShellPath("${javaHome}" + "/bin/jjs.exe")

+        homejavac = toShellPath("${javaHome}" + "/bin/javac.exe")

+    }

+    else {

+        homeJjs = toShellPath("${javaHome}" + "\\bin\\jjs.exe")

+        homejavac = toShellPath("${javaHome}" + "\\bin\\javac.exe")

+    }

+    altJjs = which('jjs.exe')

+    altjavac = which('javac.exe')

+}

 
 // Initialize default values for variables used in different functions
 var func_cond_p = <<EOD
 $EXIT == 0
 EOD

@@ -60,16 +74,15 @@
 var args_p = "-scripting"
 var args_n = "-scripting"
 
 // create file to check -flag passing
 var path_f = Paths.get("temp-flag.js")
-var testflag_file = path_f.toAbsolutePath()

+var testflag_file = toShellPath(path_f.toAbsolutePath().toString())

 
 // create file to check -flag functionality
 var path_func = Paths.get("temp-func.js")
-var testfunc_file = path_func.toAbsolutePath()

-

+var testfunc_file = toShellPath(path_func.toAbsolutePath().toString())

 
 function exists(f) {
     return Files.exists(Paths.get(f))
 }
 

@@ -80,16 +93,16 @@
     throw "no jjs executable found; tried ${homeJjs} and ${altJjs}"
 }
 
 // write code to testflag_file
 function write_testflag_file() {
-    Files.write(testflag_file, msg_flag.getBytes())

+    Files.write(Paths.get(testflag_file), msg_flag.getBytes())

 }
 
 // write code to testfunc_file
 function write_testfunc_file() {
-    Files.write(testfunc_file, msg_func.getBytes())

+    Files.write(Paths.get(testfunc_file), msg_func.getBytes())

 }
 
 function flag_test_pass() {
     print("flag test PASSED")
 }

@@ -154,12 +167,12 @@
         print("${flag} flag positive test:")
         testjjs_opt("${args_p} ${args} ${testflag_file}", true, true) // positive test
         print("${flag} flag negative test:")
         testjjs_opt("${args_n} ${testflag_file}", false, true)        // negative test
     } finally {
-        $EXEC("rm ${testflag_file}")

-        $EXEC("rm ${testfunc_file}")

+        rm("${testflag_file}")

+        rm("${testfunc_file}")

     }
 }
 
 // Main entry point to check only functionality of given -flag
 function testjjs_functionality(flag, param) {

@@ -169,11 +182,11 @@
         print("${flag} flag positive test:")
         testjjs_opt_func("${args_p} ${args} ${testfunc_file}", true) // positive test
         print("${flag} flag negative test:")
         testjjs_opt_func("${args_n} ${testfunc_file}", false)        // negative test
     } finally {
-        $EXEC("rm ${testfunc_file}")

+        rm("${testfunc_file}")

     }
 }
 
 // Main entry point to check only -flag settings for given flag
 function testjjs_flag(flag, param) {

@@ -183,8 +196,8 @@
         print("${flag} flag positive test:")
         testjjs_opt("${args_p} ${args} ${testflag_file}", true, false) // positive test
         print("${flag} flag negative test:")
         testjjs_opt("${args_n} ${testflag_file}", false, false)        // negative test
     } finally {
-        $EXEC("rm ${testflag_file}")

+        rm("${testflag_file}")

     }
 }
< prev index next >