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

Side by Side Diff: tests/standalone/io/named_pipe_script_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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 // Testing file input stream, VM-only, standalone test. 4 // Testing file input stream, VM-only, standalone test.
5 5
6 import "dart:convert"; 6 import "dart:convert";
7 import "dart:io"; 7 import "dart:io";
8 8
9 import "package:async_helper/async_helper.dart"; 9 import "package:async_helper/async_helper.dart";
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 12 matching lines...) Expand all
23 23
24 // If there's no file system access to the pipe, then we can't do a meaningful 24 // If there's no file system access to the pipe, then we can't do a meaningful
25 // test. 25 // test.
26 if (!await (new File(stdinPipePath).exists())) { 26 if (!await (new File(stdinPipePath).exists())) {
27 print("Couldn't find $stdinPipePath."); 27 print("Couldn't find $stdinPipePath.");
28 asyncEnd(); 28 asyncEnd();
29 return; 29 return;
30 } 30 }
31 31
32 StringBuffer output = new StringBuffer(); 32 StringBuffer output = new StringBuffer();
33 Process process = 33 Process process = await Process.start(Platform.executable, [stdinPipePath]);
34 await Process.start(Platform.executable, [stdinPipePath]);
35 bool stdinWriteFailed = false; 34 bool stdinWriteFailed = false;
36 process.stdout.transform(UTF8.decoder).listen(output.write); 35 process.stdout.transform(UTF8.decoder).listen(output.write);
37 process.stderr.transform(UTF8.decoder).listen((data) { 36 process.stderr.transform(UTF8.decoder).listen((data) {
38 if (!stdinWriteFailed) { 37 if (!stdinWriteFailed) {
39 Expect.fail(data); 38 Expect.fail(data);
40 process.kill(); 39 process.kill();
41 } 40 }
42 }); 41 });
43 process.stdin.done.catchError((e) { 42 process.stdin.done.catchError((e) {
44 // If the write to stdin fails, then give up. We can't test the thing we 43 // If the write to stdin fails, then give up. We can't test the thing we
45 // wanted to test. 44 // wanted to test.
46 stdinWriteFailed = true; 45 stdinWriteFailed = true;
47 process.kill(); 46 process.kill();
48 }); 47 });
49 process.stdin.writeln(script); 48 process.stdin.writeln(script);
50 await process.stdin.flush(); 49 await process.stdin.flush();
51 await process.stdin.close(); 50 await process.stdin.close();
52 51
53 int status = await process.exitCode; 52 int status = await process.exitCode;
54 if (!stdinWriteFailed) { 53 if (!stdinWriteFailed) {
55 Expect.equals(0, status); 54 Expect.equals(0, status);
56 Expect.equals("Hello, World!\n", output.toString()); 55 Expect.equals("Hello, World!\n", output.toString());
57 } 56 }
58 asyncEnd(); 57 asyncEnd();
59 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698