Index: tests/standalone/io/named_pipe_script_test.dart |
diff --git a/tests/standalone/io/named_pipe_script_test.dart b/tests/standalone/io/named_pipe_script_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..83df7375b3726db33a26aca744e9f3604e9f87ce |
--- /dev/null |
+++ b/tests/standalone/io/named_pipe_script_test.dart |
@@ -0,0 +1,32 @@ |
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+// Testing file input stream, VM-only, standalone test. |
+ |
+import "dart:convert"; |
+import "dart:io"; |
+ |
+import "package:expect/expect.dart"; |
+ |
+main() { |
+ // Reading a script from a named pipe is only supported on Linux and MacOS. |
+ if (!Platform.isLinux && !Platform.isMacOS) { |
+ return; |
+ } |
+ |
+ final String script = 'int main() {print("Hello, World!");}'; |
+ final String stdinPipePath = '/dev/fd/0'; |
+ StringBuffer output = new StringBuffer(); |
+ Process.start(Platform.executable, [stdinPipePath]).then((Process process) { |
+ process.stdout.transform(UTF8.decoder).listen(output.write); |
+ process.stderr.transform(UTF8.decoder).listen((data) { |
+ Expect.fail(data); |
+ }); |
+ process.stdin.writeln(script); |
+ process.stdin.close(); |
+ process.exitCode.then((int status) { |
+ Expect.equals(0, status); |
+ Expect.equals("Hello, World!\n", output.toString()); |
+ }); |
+ }); |
+} |