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

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

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Test a dart sub-process handling stdio with different types of 5 // Test a dart sub-process handling stdio with different types of
6 // redirection. 6 // redirection.
7 // 7 //
8 // VMOptions= 8 // VMOptions=
9 // VMOptions=--short_socket_read 9 // VMOptions=--short_socket_read
10 // VMOptions=--short_socket_write 10 // VMOptions=--short_socket_write
(...skipping 24 matching lines...) Expand all
35 35
36 // The shell script will run the dart executable passed with a 36 // The shell script will run the dart executable passed with a
37 // number of different redirections of stdio. 37 // number of different redirections of stdio.
38 String pipeOutFile = "${dir.path}/pipe"; 38 String pipeOutFile = "${dir.path}/pipe";
39 String redirectOutFile = "${dir.path}/redirect"; 39 String redirectOutFile = "${dir.path}/redirect";
40 String executable = new Options().executable; 40 String executable = new Options().executable;
41 List args = 41 List args =
42 [executable, dartScript, type, pipeOutFile, redirectOutFile]; 42 [executable, dartScript, type, pipeOutFile, redirectOutFile];
43 var future = Process.start(shellScript, args); 43 var future = Process.start(shellScript, args);
44 future.then((process) { 44 future.then((process) {
45 process.onExit = (exitCode) { 45 process.exitCode.then((exitCode) {
46 Expect.equals(0, exitCode); 46 Expect.equals(0, exitCode);
47 47
48 // Check the expected file contents. 48 // Check the expected file contents.
49 if (type == "0") { 49 if (type == "0") {
50 checkFileContent("${pipeOutFile}", "Hello\n"); 50 checkFileContent("${pipeOutFile}", "Hello\n");
51 checkFileEmpty("${redirectOutFile}.stderr"); 51 checkFileEmpty("${redirectOutFile}.stderr");
52 checkFileContent("${redirectOutFile}.stdout", "Hello\nHello\n"); 52 checkFileContent("${redirectOutFile}.stdout", "Hello\nHello\n");
53 } 53 }
54 if (type == "1") { 54 if (type == "1") {
55 checkFileContent("${pipeOutFile}", "Hello\n"); 55 checkFileContent("${pipeOutFile}", "Hello\n");
56 checkFileEmpty("${redirectOutFile}.stdout"); 56 checkFileEmpty("${redirectOutFile}.stdout");
57 checkFileContent("${redirectOutFile}.stderr", "Hello\nHello\n"); 57 checkFileContent("${redirectOutFile}.stderr", "Hello\nHello\n");
58 } 58 }
59 if (type == "2") { 59 if (type == "2") {
60 checkFileContent("${pipeOutFile}", "Hello\nHello\n"); 60 checkFileContent("${pipeOutFile}", "Hello\nHello\n");
61 checkFileContent("${redirectOutFile}.stdout", 61 checkFileContent("${redirectOutFile}.stdout",
62 "Hello\nHello\nHello\nHello\n"); 62 "Hello\nHello\nHello\nHello\n");
63 checkFileContent("${redirectOutFile}.stderr", 63 checkFileContent("${redirectOutFile}.stderr",
64 "Hello\nHello\nHello\nHello\n"); 64 "Hello\nHello\nHello\nHello\n");
65 } 65 }
66 66
67 // Cleanup test directory. 67 // Cleanup test directory.
68 dir.deleteSync(recursive: true); 68 dir.deleteSync(recursive: true);
69 }; 69 });
70 // Drain out and err streams so they close. 70 // Drain out and err streams so they close.
71 process.stdout.onData = process.stdout.read; 71 process.stdout.listen((_) {});
72 process.stderr.onData = process.stderr.read; 72 process.stderr.listen((_) {});
73 }); 73 });
74 future.catchError((error) { 74 future.catchError((error) {
75 dir.deleteSync(recursive: true); 75 dir.deleteSync(recursive: true);
76 Expect.fail(error.error.toString()); 76 Expect.fail(error.error.toString());
77 }); 77 });
78 } 78 }
79 79
80 // This tests that the Dart standalone VM can handle piping to stdin 80 // This tests that the Dart standalone VM can handle piping to stdin
81 // and can pipe to stdout. 81 // and can pipe to stdout.
82 main() { 82 main() {
(...skipping 11 matching lines...) Expand all
94 var scriptFile = new File("tests/standalone/io/process_std_io_script.dart"); 94 var scriptFile = new File("tests/standalone/io/process_std_io_script.dart");
95 if (!scriptFile.existsSync()) { 95 if (!scriptFile.existsSync()) {
96 scriptFile = new File("../tests/standalone/io/process_std_io_script.dart"); 96 scriptFile = new File("../tests/standalone/io/process_std_io_script.dart");
97 } 97 }
98 98
99 // Run the shell script. 99 // Run the shell script.
100 test(shellScript.name, scriptFile.name, "0"); 100 test(shellScript.name, scriptFile.name, "0");
101 test(shellScript.name, scriptFile.name, "1"); 101 test(shellScript.name, scriptFile.name, "1");
102 test(shellScript.name, scriptFile.name, "2"); 102 test(shellScript.name, scriptFile.name, "2");
103 } 103 }
OLDNEW
« no previous file with comments | « tests/standalone/io/chunked_stream_test.dart ('k') | tests/standalone/io/directory_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698