Chromium Code Reviews| Index: tests/standalone/io/process_shell_test.dart |
| diff --git a/tests/standalone/io/process_shell_test.dart b/tests/standalone/io/process_shell_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..28fd973e006aa5f0708245be1199a1bc5427136b |
| --- /dev/null |
| +++ b/tests/standalone/io/process_shell_test.dart |
| @@ -0,0 +1,65 @@ |
| +// 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"; |
| + |
| +void testRunShell() { |
| + test(args) { |
| + var options = new Options(); |
| + var path = new Path(options.script); |
| + path = path.directoryPath.join(new Path("process_echo_util.dart")); |
| + Process.runShell(options.executable, [path.toString()]..addAll(args)) |
| + .then((result) { |
| + 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(["'"]); |
| + test(["'\"\"'\"'\"'"]); |
| + test(["'\"\"'", "\"'\"'"]); |
| + test(["'\$HOME'"]); |
| + test(["'\$tmp'"]); |
| +} |
| + |
| +void testShell() { |
| + test(args, expected) { |
| + var options = new Options(); |
| + var path = new Path(options.script); |
| + path = path.directoryPath.join(new Path("process_echo_util.dart")); |
| + var command = options.executable; |
|
ricow1
2013/05/21 07:26:34
var command = "${options.executable} $path $args";
Anders Johnsen
2013/05/22 07:45:51
Done.
|
| + command = "$command $path"; |
| + command = "$command $args"; |
| + Process.shell(command) |
| + .then((result) { |
| + result = result.stdout.split("\n"); |
| + if (result.length - 1 != expected.length) { |
| + throw "wrong number of args: $expected vs $result"; |
| + } |
| + for (int i = 0; i < expected.length; i++) { |
| + if (expected[i] != result[i]) { |
| + throw "bad result at $i: ${expected[i]} vs ${result[i]}"; |
| + } |
| + } |
| + }); |
| + } |
| + test("arg", ["arg"]); |
| + test("arg1 arg2", ["arg1", "arg2"]); |
| + if (Platform.operatingSystem == 'windows') { |
| + test("arg1 arg2 > /dev/null", []); |
| + } |
| +} |
| + |
| +void main() { |
| + testRunShell(); |
| + testShell(); |
| +} |
| + |