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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« sdk/lib/io/process.dart ('K') | « tests/standalone/io/process_echo_util.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/process_shell_test.dart
diff --git a/tests/standalone/io/process_shell_test.dart b/tests/standalone/io/process_shell_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..28fd973e006aa5f0708245be1199a1bc5427136b
--- /dev/null
+++ b/tests/standalone/io/process_shell_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "dart:io";
+
+void testRunShell() {
+ test(args) {
+ var options = new Options();
+ var path = new Path(options.script);
+ path = path.directoryPath.join(new Path("process_echo_util.dart"));
+ Process.runShell(options.executable, [path.toString()]..addAll(args))
+ .then((result) {
+ result = result.stdout.split("\n");
+ if (result.length - 1 != args.length) {
+ throw "wrong number of args: $args vs $result";
+ }
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] != result[i]) {
+ throw "bad result at $i: ${args[i]} vs ${result[i]}";
+ }
+ }
+ });
+ }
+ test(["\""]);
+ test(["'"]);
+ test(["'\"\"'\"'\"'"]);
+ test(["'\"\"'", "\"'\"'"]);
+ test(["'\$HOME'"]);
+ test(["'\$tmp'"]);
+}
+
+void testShell() {
+ test(args, expected) {
+ var options = new Options();
+ var path = new Path(options.script);
+ path = path.directoryPath.join(new Path("process_echo_util.dart"));
+ 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.
+ command = "$command $path";
+ command = "$command $args";
+ Process.shell(command)
+ .then((result) {
+ result = result.stdout.split("\n");
+ if (result.length - 1 != expected.length) {
+ throw "wrong number of args: $expected vs $result";
+ }
+ for (int i = 0; i < expected.length; i++) {
+ if (expected[i] != result[i]) {
+ throw "bad result at $i: ${expected[i]} vs ${result[i]}";
+ }
+ }
+ });
+ }
+ test("arg", ["arg"]);
+ test("arg1 arg2", ["arg1", "arg2"]);
+ if (Platform.operatingSystem == 'windows') {
+ test("arg1 arg2 > /dev/null", []);
+ }
+}
+
+void main() {
+ testRunShell();
+ testShell();
+}
+
« 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