nashorn/test/script/trusted/JDK-8087292.js
author sundar
Thu, 03 Sep 2015 21:47:48 +0530
changeset 32443 19645ce11626
child 35794 049749629dbe
permissions -rw-r--r--
8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e" Reviewed-by: hannesw, jlaskey, mhaupt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32443
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
     1
/*
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    32
function tryExec() {
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    33
    try {
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    34
        `java`
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    35
    } catch (e) {
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    36
        print(e);
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    37
    }
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    38
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    39
    // 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
    40
    if ($EXIT == 0) {
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    41
        print("Error: expected $EXIT code to be non-zero");
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    42
    }
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    43
}
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    44
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    45
// no exception now!
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    46
tryExec();
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    47
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    48
// turn on error with non-zero exit code
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    49
$EXEC.throwOnError = true;
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    50
tryExec();
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    51
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    52
// no exception after this
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    53
$EXEC.throwOnError = false;
19645ce11626 8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar
parents:
diff changeset
    54
tryExec();