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

Unified Diff: tests/standalone/io/stdio_implicit_close_test.dart

Issue 2204953002: Don't close stdio/stderr when shutting down. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comment. Created 4 years, 4 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
« no previous file with comments | « tests/standalone/io/stdio_implicit_close_script.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/stdio_implicit_close_test.dart
diff --git a/tests/standalone/io/stdio_implicit_close_test.dart b/tests/standalone/io/stdio_implicit_close_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dc67f0ea3979ce7ff77bcf6fa829206e7c8645cd
--- /dev/null
+++ b/tests/standalone/io/stdio_implicit_close_test.dart
@@ -0,0 +1,56 @@
+// 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 "package:async_helper/async_helper.dart";
+import "package:expect/expect.dart";
+import "dart:convert";
+import "dart:io";
+
+void test({bool closeStdout, bool closeStderr}) {
+ var scriptFile = "stdio_implicit_close_script.dart";
+ var script = Platform.script.resolve(scriptFile).toFilePath();
+
+ // Relying on these flags to print something specific on stdout and stderr
+ // is brittle, but otherwise we would need to add our own flag.
+ var arguments = [
+ "--print-metrics", // Prints on stderr.
+ "--timing", // Prints on stdout.
+ script,
+ ];
+ if (closeStdout) arguments.add("stdout");
+ if (closeStderr) arguments.add("stderr");
+
+ asyncStart();
+ Process.run(Platform.executable,
+ arguments,
+ stdoutEncoding: ASCII,
+ stderrEncoding: ASCII).then((result) {
+ print(result.stdout);
+ print(result.stderr);
+ Expect.equals(0, result.exitCode);
+
+ if (closeStdout) {
+ Expect.equals("", result.stdout);
+ } else {
+ Expect.isTrue(result.stdout.contains("Timing for"));
+ }
+
+ if (closeStderr) {
+ Expect.equals("", result.stderr);
+ } else {
+ Expect.isTrue(result.stderr.contains("Printing metrics"));
+ }
+
+ asyncEnd();
+ });
+}
+
+void main() {
+ asyncStart();
+ test(closeStdout: false, closeStderr: false);
+ test(closeStdout: false, closeStderr: true);
+ test(closeStdout: true, closeStderr: false);
+ test(closeStdout: true, closeStderr: true);
+ asyncEnd();
+}
« no previous file with comments | « tests/standalone/io/stdio_implicit_close_script.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698