Files
sdk/tests/standalone/io/process_shell_test.dart
T
William Hesse 7bf2788bcc Restore all deleted tests to tests/standalone from migration to standalone_2
We are no longer deleting tests from the Dart 1 test directories when we
add them to the _2 directories. This reverts the part of change
https://dart-review.googlesource.com/c/sdk/+/12240 that modifies
the tests/standlone directory.
Bug:
Change-Id: Ie26b185234d0d18736a2fa13b77c5fd42cbb7e92
Reviewed-on: https://dart-review.googlesource.com/12287
Reviewed-by: Morten Krogh-jespersen <mkroghj@google.com>
2017-10-09 10:46:55 +00:00

69 lines
1.7 KiB
Dart

// 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.
// OtherResources=process_echo_util.dart
import "package:path/path.dart";
import "package:async_helper/async_helper.dart";
import "dart:io";
import "dart:async";
import "dart:isolate";
void testRunShell() {
test(args) {
asyncStart();
var script = Platform.script.resolve("process_echo_util.dart").toFilePath();
Process
.run(Platform.executable, [script]..addAll(args), runInShell: true)
.then((result) {
if (Platform.operatingSystem == "windows") {
result = result.stdout.split("\r\n");
} else {
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]}'";
}
}
asyncEnd();
});
}
test(["\""]);
test(["a b"]);
test(["'"]);
test(["'", "'"]);
test(["'\"\"'\"'\"'"]);
test(["'\"\"'", "\"'\"'"]);
test(["'\\\"\\\"'\\", "\"\\'\"'"]);
test(["'\$HOME'"]);
test(["'\$tmp'"]);
test(["arg'"]);
test(["arg\\'", "'\\arg"]);
}
void testBadRunShell() {
test(exe, [args = const []]) {
asyncStart();
Process.run(exe, args, runInShell: true).then((result) {
if (result.exitCode == 0) {
throw "error expected";
}
asyncEnd();
});
}
test("'\"'");
test("'\$HOME'");
}
void main() {
testRunShell();
testBadRunShell();
}