Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "dart:io"; | |
| 6 | |
| 7 void testRunShell() { | |
| 8 test(args) { | |
| 9 var options = new Options(); | |
| 10 var path = new Path(options.script); | |
| 11 path = path.directoryPath.join(new Path("process_echo_util.dart")); | |
| 12 Process.runShell(options.executable, [path.toString()]..addAll(args)) | |
| 13 .then((result) { | |
| 14 result = result.stdout.split("\n"); | |
| 15 if (result.length - 1 != args.length) { | |
| 16 throw "wrong number of args: $args vs $result"; | |
| 17 } | |
| 18 for (int i = 0; i < args.length; i++) { | |
| 19 if (args[i] != result[i]) { | |
| 20 throw "bad result at $i: ${args[i]} vs ${result[i]}"; | |
| 21 } | |
| 22 } | |
| 23 }); | |
| 24 } | |
| 25 test(["\""]); | |
| 26 test(["'"]); | |
| 27 test(["'\"\"'\"'\"'"]); | |
| 28 test(["'\"\"'", "\"'\"'"]); | |
| 29 test(["'\$HOME'"]); | |
| 30 test(["'\$tmp'"]); | |
| 31 } | |
| 32 | |
| 33 void testShell() { | |
| 34 test(args, expected) { | |
| 35 var options = new Options(); | |
| 36 var path = new Path(options.script); | |
| 37 path = path.directoryPath.join(new Path("process_echo_util.dart")); | |
| 38 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.
| |
| 39 command = "$command $path"; | |
| 40 command = "$command $args"; | |
| 41 Process.shell(command) | |
| 42 .then((result) { | |
| 43 result = result.stdout.split("\n"); | |
| 44 if (result.length - 1 != expected.length) { | |
| 45 throw "wrong number of args: $expected vs $result"; | |
| 46 } | |
| 47 for (int i = 0; i < expected.length; i++) { | |
| 48 if (expected[i] != result[i]) { | |
| 49 throw "bad result at $i: ${expected[i]} vs ${result[i]}"; | |
| 50 } | |
| 51 } | |
| 52 }); | |
| 53 } | |
| 54 test("arg", ["arg"]); | |
| 55 test("arg1 arg2", ["arg1", "arg2"]); | |
| 56 if (Platform.operatingSystem == 'windows') { | |
| 57 test("arg1 arg2 > /dev/null", []); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 void main() { | |
| 62 testRunShell(); | |
| 63 testShell(); | |
| 64 } | |
| 65 | |
| OLD | NEW |