test/script/nosecurity/JDK-8130127.js

Fri, 06 Sep 2019 03:21:30 +0100

author
andrew
date
Fri, 06 Sep 2019 03:21:30 +0100
changeset 2516
ad8af81cc28b
parent 1819
5e1012e665bf
permissions
-rw-r--r--

Added tag jdk8u242-b00 for changeset 8a951fd037e2

mhaupt@1819 1 /*
mhaupt@1819 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
mhaupt@1819 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mhaupt@1819 4 *
mhaupt@1819 5 * This code is free software; you can redistribute it and/or modify it
mhaupt@1819 6 * under the terms of the GNU General Public License version 2 only, as
mhaupt@1819 7 * published by the Free Software Foundation.
mhaupt@1819 8 *
mhaupt@1819 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mhaupt@1819 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mhaupt@1819 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mhaupt@1819 12 * version 2 for more details (a copy is included in the LICENSE file that
mhaupt@1819 13 * accompanied this code).
mhaupt@1819 14 *
mhaupt@1819 15 * You should have received a copy of the GNU General Public License version
mhaupt@1819 16 * 2 along with this work; if not, write to the Free Software Foundation,
mhaupt@1819 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mhaupt@1819 18 *
mhaupt@1819 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mhaupt@1819 20 * or visit www.oracle.com if you need additional information or have any
mhaupt@1819 21 * questions.
mhaupt@1819 22 */
mhaupt@1819 23
mhaupt@1819 24 /**
mhaupt@1819 25 * JDK-8130127: streamline input parameter of Nashorn scripting $EXEC function
mhaupt@1819 26 *
mhaupt@1819 27 * Test different variants of stdin passing to $EXEC.
mhaupt@1819 28 *
mhaupt@1819 29 * @test
mhaupt@1819 30 * @option -scripting
mhaupt@1819 31 * @run
mhaupt@1819 32 */
mhaupt@1819 33
mhaupt@1819 34 var File = java.io.File,
mhaupt@1819 35 sep = File.separator,
mhaupt@1819 36 System = java.lang.System,
mhaupt@1819 37 os = System.getProperty("os.name"),
mhaupt@1819 38 win = os.startsWith("Windows"),
mhaupt@1819 39 jjsName = "jjs" + (win ? ".exe" : ""),
mhaupt@1819 40 javaHome = System.getProperty("java.home")
mhaupt@1819 41
mhaupt@1819 42 var jjs = javaHome + "/../bin/".replace(/\//g, sep) + jjsName
mhaupt@1819 43 if (!new File(jjs).isFile()) {
mhaupt@1819 44 jjs = javaHome + "/bin/".replace(/\//g, sep) + jjsName
mhaupt@1819 45 }
mhaupt@1819 46
mhaupt@1819 47 var jjsCmd = jjs + " readprint.js"
mhaupt@1819 48
mhaupt@1819 49 print($EXEC(jjsCmd))
mhaupt@1819 50 print($EXEC(jjsCmd, null))
mhaupt@1819 51 print($EXEC(jjsCmd, undefined))
mhaupt@1819 52 print($EXEC(jjsCmd, ""))
mhaupt@1819 53
mhaupt@1819 54 print($EXEC(jjs, "print('hello')"))
mhaupt@1819 55

mercurial