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

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

Issue 2641673002: Gardening: Fix previous fix (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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";
11 11
12 main() async { 12 main() async {
13 asyncStart(); 13 asyncStart();
14 // Reading a script from a named pipe is only supported on Linux and MacOS. 14 // Reading a script from a named pipe is only supported on Linux and MacOS.
15 if (!Platform.isLinux && !Platform.isMacOS) { 15 if (!Platform.isLinux && !Platform.isMacOS) {
16 print("This test is only supported on Linux and MacOS."); 16 print("This test is only supported on Linux and MacOS.");
17 asyncEnd();
17 return; 18 return;
18 } 19 }
19 20
20 final String script = 'main() { print("Hello, World!"); }'; 21 final String script = 'main() { print("Hello, World!"); }';
21 final String stdinPipePath = '/dev/fd/0'; 22 final String stdinPipePath = '/dev/fd/0';
22 23
23 // 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
24 // test. 25 // test.
25 if (!await (new File(stdinPipePath).exists())) { 26 if (!await (new File(stdinPipePath).exists())) {
26 print("Couldn't find $stdinPipePath."); 27 print("Couldn't find $stdinPipePath.");
28 asyncEnd();
27 return; 29 return;
28 } 30 }
29 31
30 StringBuffer output = new StringBuffer(); 32 StringBuffer output = new StringBuffer();
31 Process process = 33 Process process =
32 await Process.start(Platform.executable, ['--checked', stdinPipePath]); 34 await Process.start(Platform.executable, ['--checked', stdinPipePath]);
33 bool stdinWriteFailed = false; 35 bool stdinWriteFailed = false;
34 process.stdout.transform(UTF8.decoder).listen(output.write); 36 process.stdout.transform(UTF8.decoder).listen(output.write);
35 process.stderr.transform(UTF8.decoder).listen((data) { 37 process.stderr.transform(UTF8.decoder).listen((data) {
36 if (!stdinWriteFailed) { 38 if (!stdinWriteFailed) {
(...skipping 10 matching lines...) Expand all
47 process.stdin.writeln(script); 49 process.stdin.writeln(script);
48 process.stdin.close(); 50 process.stdin.close();
49 51
50 int status = await process.exitCode; 52 int status = await process.exitCode;
51 if (!stdinWriteFailed) { 53 if (!stdinWriteFailed) {
52 Expect.equals(0, status); 54 Expect.equals(0, status);
53 Expect.equals("Hello, World!\n", output.toString()); 55 Expect.equals("Hello, World!\n", output.toString());
54 } 56 }
55 asyncEnd(); 57 asyncEnd();
56 } 58 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698