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

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: Remove Process.shell and clean up 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 result = result.stdout.split("\n");
15 print(result);
16 if (result.length - 1 != args.length) {
17 throw "wrong number of args: $args vs $result";
18 }
19 for (int i = 0; i < args.length; i++) {
20 if (args[i] != result[i]) {
21 throw "bad result at $i: ${args[i]} vs ${result[i]}";
22 }
23 }
24 });
25 }
26 test(["\""]);
27 test(["'"]);
28 test(["'\"\"'\"'\"'"]);
29 test(["'\"\"'", "\"'\"'"]);
30 test(["'\$HOME'"]);
31 test(["'\$tmp'"]);
32 }
33
34 void testShell() {
35 test(args, expected) {
36 var options = new Options();
37 var path = new Path(options.script);
38 path = path.directoryPath.join(new Path("process_echo_util.dart"));
39 var command = "${options.executable} $path $args";
40 Process.runShell(command, [])
41 .then((result) {
42 result = result.stdout.split("\n");
43 if (result.length - 1 != expected.length) {
44 throw "wrong number of args: $expected vs $result";
45 }
46 for (int i = 0; i < expected.length; i++) {
47 if (expected[i] != result[i]) {
48 throw "bad result at $i: ${expected[i]} vs ${result[i]}";
49 }
50 }
51 });
52 }
53 test("arg", ["arg"]);
54 test("arg1 arg2", ["arg1", "arg2"]);
55 if (Platform.operatingSystem != 'windows') {
56 test("arg1 arg2 > /dev/null", []);
57 }
58 }
59
60 void main() {
61 testRunShell();
62 testShell();
63 }
64
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