author | aefimov |
Tue, 10 Jan 2017 22:15:54 +0300 | |
changeset 43126 | 26c4004e8cc0 |
parent 36483 | 2bc58b5e99d3 |
permissions | -rw-r--r-- |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
1 |
/* |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
4 |
* |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
8 |
* |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
14 |
* |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
18 |
* |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
21 |
* questions. |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
22 |
*/ |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
23 |
|
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
24 |
/** |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
25 |
* JDK-8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e" |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
26 |
* |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
27 |
* @test |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
28 |
* @option -scripting |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
29 |
* @run |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
30 |
*/ |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
31 |
|
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
32 |
load(__DIR__ + "JDK-util.js") |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
33 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
34 |
var jHomePath = System.getenv("JAVA_HOME") |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
35 |
var jLauncher = "${jHomePath}/bin/java" |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
36 |
var altjLauncher = which('java') |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
37 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
38 |
if (windows) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
39 |
if(winCyg) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
40 |
jLauncher = "${jHomePath}" + "/bin/java.exe" |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
41 |
jLauncher = cygpath(jLauncher,outPath.windows) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
42 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
43 |
else { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
44 |
jLauncher = "${jHomePath}" + "\\bin\\java.exe" |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
45 |
altjLauncher = which('java.exe') |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
46 |
altjLauncher = cygpath(altjLauncher,outPath.windows) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
47 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
48 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
49 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
50 |
function exists(f) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
51 |
return Files.exists(Paths.get(f)) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
52 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
53 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
54 |
var javaLauncher = exists(jLauncher) ? jLauncher : altjLauncher |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
55 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
56 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
57 |
if (!exists(javaLauncher)) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
58 |
throw "no java launcher found; tried ${jLauncher} and ${altjLauncher}" |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
59 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
60 |
|
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
61 |
function tryExec() { |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
62 |
try { |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
63 |
$EXEC("${javaLauncher}") |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
64 |
} catch (e) { |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
65 |
print(e) |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
66 |
} |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
67 |
|
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
68 |
// make sure we got non-zero ("failure") exit code! |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
69 |
if ($EXIT == 0) { |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
70 |
print("Error: expected $EXIT code to be non-zero") |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
71 |
} |
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
72 |
} |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
73 |
//convert windows paths to cygwin |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
74 |
if (windows) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
75 |
javaLauncher = (winCyg) ? cygpath(javaLauncher,outPath.mixed).trim() : cygpath(javaLauncher,outPath.windows).trim() |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
76 |
|
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
77 |
// no exception now! |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
78 |
tryExec() |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
79 |
|
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
80 |
// turn on error with non-zero exit code |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
81 |
$ENV.JJS_THROW_ON_EXIT = "1" |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
82 |
tryExec() |
32443
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
83 |
|
19645ce11626
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff
changeset
|
84 |
// no exception after this |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
85 |
$ENV.JJS_THROW_ON_EXIT = "0" |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
35794
diff
changeset
|
86 |
tryExec() |