Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: tests/standalone/io/process_shell_test.dart

Issue 15299004: Add Process.shell and Process.runShell. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows impl. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 if (Platform.operatingSystem == "windows") {
15 result = result.stdout.split("\r\n");
16 } else {
17 result = result.stdout.split("\n");
18 }
19 if (result.length - 1 != args.length) {
20 throw "wrong number of args: $args vs $result";
21 }
22 for (int i = 0; i < args.length; i++) {
23 if (args[i] != result[i]) {
24 throw "bad result at $i: '${args[i]}' vs '${result[i]}'";
25 }
26 }
27 });
28 }
29 test(["\""]);
30 test(["a b"]);
31 test(["'"]);
32 test(["'\"\"'\"'\"'"]);
33 test(["'\"\"'", "\"'\"'"]);
34 test(["'\$HOME'"]);
35 test(["'\$tmp'"]);
36 }
37
38 void testShell() {
39 test(args, expected) {
40 var options = new Options();
41 var path = new Path(options.script);
42 path = path.directoryPath.join(new Path("process_echo_util.dart"));
43 var command = "${options.executable} $path $args";
44 Process.runShell(command, [])
45 .then((result) {
46 if (Platform.operatingSystem == "windows") {
47 result = result.stdout.split("\r\n");
48 } else {
49 result = result.stdout.split("\n");
50 }
51 if (result.length - 1 != expected.length) {
52 throw "wrong number of args: $expected vs $result";
53 }
54 for (int i = 0; i < expected.length; i++) {
55 if (expected[i] != result[i]) {
56 throw "bad result at $i: ${expected[i]} vs ${result[i]}";
57 }
58 }
59 });
60 }
61 test("arg", ["arg"]);
62 test("arg1 arg2", ["arg1", "arg2"]);
63 if (Platform.operatingSystem != 'windows') {
64 test("arg1 arg2 > /dev/null", []);
65 }
66 }
67
68 void main() {
69 testRunShell();
70 testShell();
71 }
72
OLDNEW
« sdk/lib/io/process.dart ('K') | « tests/standalone/io/process_echo_util.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698