author | sdama |
Mon, 21 Mar 2016 12:38:23 +0100 | |
changeset 36689 | 3370f6f942ff |
parent 36480 | 1a873ecd2249 |
permissions | -rw-r--r-- |
36479 | 1 |
/* |
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* Test $EXEC and $ENV.PWD handling across platforms. |
|
26 |
* There must be a java executable in the PATH. |
|
27 |
* |
|
28 |
* @test |
|
29 |
* @option -scripting |
|
36689 | 30 |
* @runif os.not.windows.cmd |
36479 | 31 |
*/ |
32 |
||
33 |
$EXEC(["java", "-version"]) |
|
34 |
if ($EXIT != 0) { |
|
35 |
throw 'java executable problem: ' + $ERR |
|
36 |
} |
|
37 |
||
38 |
function eq(p, q, e) { |
|
39 |
if (p != q) { |
|
40 |
throw e |
|
41 |
} |
|
42 |
} |
|
43 |
||
44 |
function neq(p, q, e) { |
|
45 |
if (p == q) { |
|
46 |
throw e |
|
47 |
} |
|
48 |
} |
|
49 |
||
50 |
var File = Java.type("java.io.File"), |
|
51 |
System = Java.type("java.lang.System"), |
|
52 |
win = System.getProperty("os.name").startsWith("Windows"), |
|
53 |
sep = File.separator, |
|
54 |
startwd = $ENV.PWD, |
|
55 |
upwd = startwd.substring(0, startwd.lastIndexOf(sep)) |
|
56 |
||
57 |
$EXEC("ls") |
|
58 |
var ls_startwd = $OUT |
|
59 |
$EXEC("cd ..; ls") |
|
60 |
var ls_cdupwd = $OUT |
|
61 |
eq($ENV.PWD, startwd, 'PWD changed during $EXEC cd') |
|
36480
1a873ecd2249
8151518: relax test requirements to reduce dependency on directory contents
mhaupt
parents:
36479
diff
changeset
|
62 |
neq(ls_startwd, ls_cdupwd, 'same ls result for startwd and upwd with $EXEC cd') |
36479 | 63 |
|
64 |
$ENV.PWD = upwd |
|
65 |
eq($ENV.PWD, upwd, '$ENV.PWD change had no effect') |
|
66 |
$EXEC("ls") |
|
67 |
var ls_epupwd = $OUT |
|
36480
1a873ecd2249
8151518: relax test requirements to reduce dependency on directory contents
mhaupt
parents:
36479
diff
changeset
|
68 |
neq(ls_startwd, ls_epupwd, 'same ls result for startwd and upwd with $ENV.PWD cd') |