OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Testing file input stream, VM-only, standalone test. |
| 5 |
| 6 import "dart:convert"; |
| 7 import "dart:io"; |
| 8 |
| 9 import "package:expect/expect.dart"; |
| 10 |
| 11 main() { |
| 12 // Reading a script from a named pipe is only supported on Linux and MacOS. |
| 13 if (!Platform.isLinux && !Platform.isMacOS) { |
| 14 return; |
| 15 } |
| 16 |
| 17 final String script = 'int main() {print("Hello, World!");}'; |
| 18 final String stdinPipePath = '/dev/fd/0'; |
| 19 StringBuffer output = new StringBuffer(); |
| 20 Process.start(Platform.executable, [stdinPipePath]).then((Process process) { |
| 21 process.stdout.transform(UTF8.decoder).listen(output.write); |
| 22 process.stderr.transform(UTF8.decoder).listen((data) { |
| 23 Expect.fail(data); |
| 24 }); |
| 25 process.stdin.writeln(script); |
| 26 process.stdin.close(); |
| 27 process.exitCode.then((int status) { |
| 28 Expect.equals(0, status); |
| 29 Expect.equals("Hello, World!\n", output.toString()); |
| 30 }); |
| 31 }); |
| 32 } |
OLD | NEW |