| OLD | NEW |
| 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 |
| 11 // VMOptions=--short_socket_read --short_socket_write | 11 // VMOptions=--short_socket_read --short_socket_write |
| 12 | 12 |
| 13 import "package:expect/expect.dart"; | 13 import "package:expect/expect.dart"; |
| 14 import "dart:io"; | 14 import "dart:io"; |
| 15 import "process_test_util.dart"; | 15 import "process_test_util.dart"; |
| 16 | 16 |
| 17 void checkFileEmpty(String fileName) { | 17 void checkFileEmpty(String fileName) { |
| 18 RandomAccessFile pipeOut = new File(fileName).openSync(); | 18 RandomAccessFile pipeOut = new File(fileName).openSync(); |
| 19 Expect.equals(0, pipeOut.lengthSync()); | 19 Expect.equals(0, pipeOut.lengthSync()); |
| 20 pipeOut.closeSync(); | 20 pipeOut.closeSync(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 | 23 |
| 24 void checkFileContent(String fileName, String content) { | 24 void checkFileContent(String fileName, String content) { |
| 25 RandomAccessFile pipeOut = new File(fileName).openSync(); | 25 RandomAccessFile pipeOut = new File(fileName).openSync(); |
| 26 int length = pipeOut.lengthSync(); | 26 int length = pipeOut.lengthSync(); |
| 27 List data = new List<int>(length); | 27 List data = new List<int>(length); |
| 28 pipeOut.readListSync(data, 0, length); | 28 pipeOut.readIntoSync(data, 0, length); |
| 29 Expect.equals(content, new String.fromCharCodes(data)); | 29 Expect.equals(content, new String.fromCharCodes(data)); |
| 30 pipeOut.closeSync(); | 30 pipeOut.closeSync(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 void test(String shellScript, String dartScript, String type, bool devNull) { | 34 void test(String shellScript, String dartScript, String type, bool devNull) { |
| 35 Directory dir = new Directory("").createTempSync(); | 35 Directory dir = new Directory("").createTempSync(); |
| 36 | 36 |
| 37 // The shell script will run the dart executable passed with a | 37 // The shell script will run the dart executable passed with a |
| 38 // number of different redirections of stdio. | 38 // number of different redirections of stdio. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Run the shell script. | 120 // Run the shell script. |
| 121 test(shellScript.path, scriptFile.path, "0", false); | 121 test(shellScript.path, scriptFile.path, "0", false); |
| 122 test(shellScript.path, scriptFile.path, "0", true); | 122 test(shellScript.path, scriptFile.path, "0", true); |
| 123 test(shellScript.path, scriptFile.path, "1", false); | 123 test(shellScript.path, scriptFile.path, "1", false); |
| 124 test(shellScript.path, scriptFile.path, "1", true); | 124 test(shellScript.path, scriptFile.path, "1", true); |
| 125 test(shellScript.path, scriptFile.path, "2", false); | 125 test(shellScript.path, scriptFile.path, "2", false); |
| 126 test(shellScript.path, scriptFile.path, "2", true); | 126 test(shellScript.path, scriptFile.path, "2", true); |
| 127 } | 127 } |
| OLD | NEW |