| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:path/path.dart"; |
| 5 import "dart:io"; | 6 import "dart:io"; |
| 6 import "dart:isolate"; | 7 import "dart:isolate"; |
| 7 | 8 |
| 8 void testRunShell() { | 9 void testRunShell() { |
| 9 test(args) { | 10 test(args) { |
| 10 var path = new Path(Platform.script); | 11 var path = join(dirname(Platform.script), "process_echo_util.dart"); |
| 11 path = path.directoryPath.join(new Path("process_echo_util.dart")); | |
| 12 Process.run(Platform.executable, | 12 Process.run(Platform.executable, |
| 13 [path.toString()]..addAll(args), | 13 [path]..addAll(args), |
| 14 runInShell: true) | 14 runInShell: true) |
| 15 .then((result) { | 15 .then((result) { |
| 16 if (Platform.operatingSystem == "windows") { | 16 if (Platform.operatingSystem == "windows") { |
| 17 result = result.stdout.split("\r\n"); | 17 result = result.stdout.split("\r\n"); |
| 18 } else { | 18 } else { |
| 19 result = result.stdout.split("\n"); | 19 result = result.stdout.split("\n"); |
| 20 } | 20 } |
| 21 if (result.length - 1 != args.length) { | 21 if (result.length - 1 != args.length) { |
| 22 throw "wrong number of args: $args vs $result"; | 22 throw "wrong number of args: $args vs $result"; |
| 23 } | 23 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 test(["'\"\"'", "\"'\"'"]); | 36 test(["'\"\"'", "\"'\"'"]); |
| 37 test(["'\\\"\\\"'\\", "\"\\'\"'"]); | 37 test(["'\\\"\\\"'\\", "\"\\'\"'"]); |
| 38 test(["'\$HOME'"]); | 38 test(["'\$HOME'"]); |
| 39 test(["'\$tmp'"]); | 39 test(["'\$tmp'"]); |
| 40 test(["arg'"]); | 40 test(["arg'"]); |
| 41 test(["arg\\'", "'\\arg"]); | 41 test(["arg\\'", "'\\arg"]); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void testBadRunShell() { | 44 void testBadRunShell() { |
| 45 test(exe, [args = const []]) { | 45 test(exe, [args = const []]) { |
| 46 var path = new Path(Platform.script); | |
| 47 path = path.directoryPath.join(new Path("process_echo_util.dart")); | |
| 48 Process.run(exe, args, runInShell: true) | 46 Process.run(exe, args, runInShell: true) |
| 49 .then((result) { | 47 .then((result) { |
| 50 port.close(); | 48 port.close(); |
| 51 if (result.exitCode == 0) { | 49 if (result.exitCode == 0) { |
| 52 throw "error expected"; | 50 throw "error expected"; |
| 53 } | 51 } |
| 54 }); | 52 }); |
| 55 } | 53 } |
| 56 test("'\"'"); | 54 test("'\"'"); |
| 57 test("'\$HOME'"); | 55 test("'\$HOME'"); |
| 58 } | 56 } |
| 59 | 57 |
| 60 void main() { | 58 void main() { |
| 61 testRunShell(); | 59 testRunShell(); |
| 62 testBadRunShell(); | 60 testBadRunShell(); |
| 63 } | 61 } |
| 64 | 62 |
| OLD | NEW |