OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // OtherResources=file_read_stdio_script.dart | 5 // OtherResources=file_read_stdio_script.dart |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'package:path/path.dart'; | 8 import 'package:path/path.dart'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
11 void openAndWriteScript(String script) { | 11 void openAndWriteScript(String script) { |
12 script = Platform.script.resolve(script).toFilePath(); | 12 script = Platform.script.resolve(script).toFilePath(); |
13 var executable = Platform.executable; | 13 var executable = Platform.executable; |
14 var file = script; // Use script as file. | 14 var file = script; // Use script as file. |
15 Process.start("bash", ["-c", "$executable $script < $file"]).then((process) { | 15 Process.start("bash", ["-c", "$executable $script < $file"]).then((process) { |
16 process.exitCode | 16 process.exitCode.then((exitCode) { |
17 .then((exitCode) { | 17 Expect.equals(0, exitCode); |
18 Expect.equals(0, exitCode); | 18 }); |
19 }); | |
20 }); | 19 }); |
21 } | 20 } |
22 | 21 |
23 void testReadStdio() { | 22 void testReadStdio() { |
24 openAndWriteScript("file_read_stdio_script.dart"); | 23 openAndWriteScript("file_read_stdio_script.dart"); |
25 } | 24 } |
26 | 25 |
27 void main() { | 26 void main() { |
28 // Special unix devices do not exist on Windows. | 27 // Special unix devices do not exist on Windows. |
29 if (Platform.operatingSystem != 'windows') { | 28 if (Platform.operatingSystem != 'windows') { |
30 testReadStdio(); | 29 testReadStdio(); |
31 } | 30 } |
32 } | 31 } |
OLD | NEW |