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