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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // OtherResources=stdio_implicit_close_script.dart 5 // OtherResources=stdio_implicit_close_script.dart
6 6
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import "dart:convert"; 9 import "dart:convert";
10 import "dart:io"; 10 import "dart:io";
11 11
12 void test({bool closeStdout, bool closeStderr}) { 12 void test({bool closeStdout, bool closeStderr}) {
13 var scriptFile = "stdio_implicit_close_script.dart"; 13 var scriptFile = "stdio_implicit_close_script.dart";
14 var script = Platform.script.resolve(scriptFile).toFilePath(); 14 var script = Platform.script.resolve(scriptFile).toFilePath();
15 15
16 // Relying on these flags to print something specific on stdout and stderr 16 // Relying on these flags to print something specific on stdout and stderr
17 // is brittle, but otherwise we would need to add our own flag. 17 // is brittle, but otherwise we would need to add our own flag.
18 var arguments = [ 18 var arguments = [
19 "--print-metrics", // Prints on stderr. 19 "--print-metrics", // Prints on stderr.
20 "--timing", // Prints on stdout. 20 "--timing", // Prints on stdout.
21 script, 21 script,
22 ]; 22 ];
23 if (closeStdout) arguments.add("stdout"); 23 if (closeStdout) arguments.add("stdout");
24 if (closeStderr) arguments.add("stderr"); 24 if (closeStderr) arguments.add("stderr");
25 25
26 asyncStart(); 26 asyncStart();
27 Process.run(Platform.executable, 27 Process
28 arguments, 28 .run(Platform.executable, arguments,
29 stdoutEncoding: ASCII, 29 stdoutEncoding: ASCII, stderrEncoding: ASCII)
30 stderrEncoding: ASCII).then((result) { 30 .then((result) {
31 print(result.stdout); 31 print(result.stdout);
32 print(result.stderr); 32 print(result.stderr);
33 Expect.equals(0, result.exitCode); 33 Expect.equals(0, result.exitCode);
34 34
35 if (closeStdout) { 35 if (closeStdout) {
36 Expect.equals("", result.stdout); 36 Expect.equals("", result.stdout);
37 } else { 37 } else {
38 Expect.isTrue(result.stdout.contains("Timing for")); 38 Expect.isTrue(result.stdout.contains("Timing for"));
39 } 39 }
40 40
41 if (closeStderr) { 41 if (closeStderr) {
42 Expect.equals("", result.stderr); 42 Expect.equals("", result.stderr);
43 } else { 43 } else {
44 Expect.isTrue(result.stderr.contains("Printing metrics")); 44 Expect.isTrue(result.stderr.contains("Printing metrics"));
45 } 45 }
46 46
47 asyncEnd(); 47 asyncEnd();
48 }); 48 });
49 } 49 }
50 50
51 void main() { 51 void main() {
52 asyncStart(); 52 asyncStart();
53 test(closeStdout: false, closeStderr: false); 53 test(closeStdout: false, closeStderr: false);
54 test(closeStdout: false, closeStderr: true); 54 test(closeStdout: false, closeStderr: true);
55 test(closeStdout: true, closeStderr: false); 55 test(closeStdout: true, closeStderr: false);
56 test(closeStdout: true, closeStderr: true); 56 test(closeStdout: true, closeStderr: true);
57 asyncEnd(); 57 asyncEnd();
58 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698