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