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

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

Issue 10392023: Change dart:io to use Future for one-shot operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor cleanup Created 8 years, 7 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 13 matching lines...) Expand all
24 RandomAccessFile pipeOut = new File(fileName).openSync(); 24 RandomAccessFile pipeOut = new File(fileName).openSync();
25 int length = pipeOut.lengthSync(); 25 int length = pipeOut.lengthSync();
26 List data = new List<int>(length); 26 List data = new List<int>(length);
27 pipeOut.readListSync(data, 0, length); 27 pipeOut.readListSync(data, 0, length);
28 Expect.equals(content, new String.fromCharCodes(data)); 28 Expect.equals(content, new String.fromCharCodes(data));
29 pipeOut.closeSync(); 29 pipeOut.closeSync();
30 } 30 }
31 31
32 32
33 void test(String shellScript, String dartScript, String type) { 33 void test(String shellScript, String dartScript, String type) {
34 Directory dir = new Directory(""); 34 Directory dir = new Directory("").createTempSync();
35 dir.createTempSync();
36 35
37 // The shell script will run the dart executable passed with a 36 // The shell script will run the dart executable passed with a
38 // number of different redirections of stdio. 37 // number of different redirections of stdio.
39 String pipeOutFile = "${dir.path}/pipe"; 38 String pipeOutFile = "${dir.path}/pipe";
40 String redirectOutFile = "${dir.path}/redirect"; 39 String redirectOutFile = "${dir.path}/redirect";
41 String executable = new Options().executable; 40 String executable = new Options().executable;
42 List args = 41 List args =
43 [executable, dartScript, type, pipeOutFile, redirectOutFile]; 42 [executable, dartScript, type, pipeOutFile, redirectOutFile];
44 Process process = new Process.start(shellScript, args); 43 InteractiveProcess process = Process.start(shellScript, args);
45 44
46 // Wait for the process to exit and then check result. 45 // Wait for the process to exit and then check result.
47 process.onExit = (exitCode) { 46 process.onExit = (exitCode) {
48 Expect.equals(0, exitCode); 47 Expect.equals(0, exitCode);
49 process.close(); 48 process.close();
50 49
51 // Check the expected file contents. 50 // Check the expected file contents.
52 if (type == "0") { 51 if (type == "0") {
53 checkFileContent("${pipeOutFile}", "Hello\n"); 52 checkFileContent("${pipeOutFile}", "Hello\n");
54 checkFileEmpty("${redirectOutFile}.stderr"); 53 checkFileEmpty("${redirectOutFile}.stderr");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 var scriptFile = new File("tests/standalone/io/process_std_io_script.dart"); 92 var scriptFile = new File("tests/standalone/io/process_std_io_script.dart");
94 if (!scriptFile.existsSync()) { 93 if (!scriptFile.existsSync()) {
95 scriptFile = new File("../tests/standalone/io/process_std_io_script.dart"); 94 scriptFile = new File("../tests/standalone/io/process_std_io_script.dart");
96 } 95 }
97 96
98 // Run the shell script. 97 // Run the shell script.
99 test(shellScript.name, scriptFile.name, "0"); 98 test(shellScript.name, scriptFile.name, "0");
100 test(shellScript.name, scriptFile.name, "1"); 99 test(shellScript.name, scriptFile.name, "1");
101 test(shellScript.name, scriptFile.name, "2"); 100 test(shellScript.name, scriptFile.name, "2");
102 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698