test/script/trusted/JDK-8087292.js

Wed, 16 Mar 2016 00:10:12 -0700

author
asaha
date
Wed, 16 Mar 2016 00:10:12 -0700
changeset 1746
09abd795d1d1
parent 1525
e93960ae0b1e
child 1838
be4ef6af7d3d
permissions
-rw-r--r--

Added tag jdk8u77-b01 for changeset 678b645aa10a

sundar@1525 1 /*
sundar@1525 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
sundar@1525 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sundar@1525 4 *
sundar@1525 5 * This code is free software; you can redistribute it and/or modify it
sundar@1525 6 * under the terms of the GNU General Public License version 2 only, as
sundar@1525 7 * published by the Free Software Foundation.
sundar@1525 8 *
sundar@1525 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sundar@1525 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sundar@1525 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sundar@1525 12 * version 2 for more details (a copy is included in the LICENSE file that
sundar@1525 13 * accompanied this code).
sundar@1525 14 *
sundar@1525 15 * You should have received a copy of the GNU General Public License version
sundar@1525 16 * 2 along with this work; if not, write to the Free Software Foundation,
sundar@1525 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sundar@1525 18 *
sundar@1525 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sundar@1525 20 * or visit www.oracle.com if you need additional information or have any
sundar@1525 21 * questions.
sundar@1525 22 */
sundar@1525 23
sundar@1525 24 /**
sundar@1525 25 * JDK-8087292: nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
sundar@1525 26 *
sundar@1525 27 * @test
sundar@1525 28 * @option -scripting
sundar@1525 29 * @run
sundar@1525 30 */
sundar@1525 31
sundar@1525 32 function tryExec() {
sundar@1525 33 try {
sundar@1525 34 `java`
sundar@1525 35 } catch (e) {
sundar@1525 36 print(e);
sundar@1525 37 }
sundar@1525 38
sundar@1525 39 // make sure we got non-zero ("failure") exit code!
sundar@1525 40 if ($EXIT == 0) {
sundar@1525 41 print("Error: expected $EXIT code to be non-zero");
sundar@1525 42 }
sundar@1525 43 }
sundar@1525 44
sundar@1525 45 // no exception now!
sundar@1525 46 tryExec();
sundar@1525 47
sundar@1525 48 // turn on error with non-zero exit code
sundar@1525 49 $EXEC.throwOnError = true;
sundar@1525 50 tryExec();
sundar@1525 51
sundar@1525 52 // no exception after this
sundar@1525 53 $EXEC.throwOnError = false;
sundar@1525 54 tryExec();

mercurial