887c8e7596
The getters for executable, script and version are now statics on Platform. I kept them on Options for now, but updated most tests to use Platform. R=ajohnsen@google.com, floitsch@google.com, iposva@google.com BUG= Review URL: https://codereview.chromium.org//17406010 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24401 260f80e4-7a28-3924-810f-c04153c831b5
65 lines
1.7 KiB
Dart
65 lines
1.7 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "dart:io";
|
|
import "dart:isolate";
|
|
|
|
void testRunShell() {
|
|
test(args) {
|
|
var path = new Path(Platform.script);
|
|
path = path.directoryPath.join(new Path("process_echo_util.dart"));
|
|
Process.run(Platform.executable,
|
|
[path.toString()]..addAll(args),
|
|
runInShell: true)
|
|
.then((result) {
|
|
if (Platform.operatingSystem == "windows") {
|
|
result = result.stdout.split("\r\n");
|
|
} else {
|
|
result = result.stdout.split("\n");
|
|
}
|
|
if (result.length - 1 != args.length) {
|
|
throw "wrong number of args: $args vs $result";
|
|
}
|
|
for (int i = 0; i < args.length; i++) {
|
|
if (args[i] != result[i]) {
|
|
throw "bad result at $i: '${args[i]}' vs '${result[i]}'";
|
|
}
|
|
}
|
|
});
|
|
}
|
|
test(["\""]);
|
|
test(["a b"]);
|
|
test(["'"]);
|
|
test(["'", "'"]);
|
|
test(["'\"\"'\"'\"'"]);
|
|
test(["'\"\"'", "\"'\"'"]);
|
|
test(["'\\\"\\\"'\\", "\"\\'\"'"]);
|
|
test(["'\$HOME'"]);
|
|
test(["'\$tmp'"]);
|
|
test(["arg'"]);
|
|
test(["arg\\'", "'\\arg"]);
|
|
}
|
|
|
|
void testBadRunShell() {
|
|
test(exe, [args = const []]) {
|
|
var path = new Path(Platform.script);
|
|
path = path.directoryPath.join(new Path("process_echo_util.dart"));
|
|
Process.run(exe, args, runInShell: true)
|
|
.then((result) {
|
|
port.close();
|
|
if (result.exitCode == 0) {
|
|
throw "error expected";
|
|
}
|
|
});
|
|
}
|
|
test("'\"'");
|
|
test("'\$HOME'");
|
|
}
|
|
|
|
void main() {
|
|
testRunShell();
|
|
testBadRunShell();
|
|
}
|
|
|