OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
10 import 'package:async_helper/async_helper.dart'; | 10 import 'package:async_helper/async_helper.dart'; |
11 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
12 | 12 |
13 import 'launch_helper.dart' show dart2JsCommand; | 13 import 'launch_helper.dart' show dart2JsCommand; |
14 | 14 |
15 var tmpDir; | 15 var tmpDir; |
16 | 16 |
17 copyDirectory(Directory sourceDir, Directory destinationDir) { | 17 copyDirectory(Directory sourceDir, Directory destinationDir) { |
18 sourceDir.listSync().forEach((FileSystemEntity element) { | 18 sourceDir.listSync().forEach((FileSystemEntity element) { |
19 String newPath = path.join(destinationDir.path, | 19 String newPath = |
20 path.basename(element.path)); | 20 path.join(destinationDir.path, path.basename(element.path)); |
21 if (element is File) { | 21 if (element is File) { |
22 element.copySync(newPath); | 22 element.copySync(newPath); |
23 } else if (element is Directory) { | 23 } else if (element is Directory) { |
24 Directory newDestinationDir = new Directory(newPath); | 24 Directory newDestinationDir = new Directory(newPath); |
25 newDestinationDir.createSync(); | 25 newDestinationDir.createSync(); |
26 copyDirectory(element, newDestinationDir); | 26 copyDirectory(element, newDestinationDir); |
27 } | 27 } |
28 }); | 28 }); |
29 } | 29 } |
30 | 30 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 String outFile = path.join(tmpDir.path, 'out.js'); | 65 String outFile = path.join(tmpDir.path, 'out.js'); |
66 String outFile2 = path.join(tmpDir.path, 'out2.js'); | 66 String outFile2 = path.join(tmpDir.path, 'out2.js'); |
67 | 67 |
68 process.stdin.writeln('--out="$outFile" "$inFile"'); | 68 process.stdin.writeln('--out="$outFile" "$inFile"'); |
69 process.stdin.writeln('--out="$outFile2" "$inFile"'); | 69 process.stdin.writeln('--out="$outFile2" "$inFile"'); |
70 process.stdin.writeln('too many arguments'); | 70 process.stdin.writeln('too many arguments'); |
71 process.stdin.writeln(r'"non existing file.dart"'); | 71 process.stdin.writeln(r'"non existing file.dart"'); |
72 process.stdin.close(); | 72 process.stdin.close(); |
73 Future<String> output = process.stdout.transform(UTF8.decoder).join(); | 73 Future<String> output = process.stdout.transform(UTF8.decoder).join(); |
74 Future<String> errorOut = process.stderr.transform(UTF8.decoder).join(); | 74 Future<String> errorOut = process.stderr.transform(UTF8.decoder).join(); |
75 return Future.wait([output, errorOut]) | 75 return Future.wait([output, errorOut]).then((result) { |
76 .then((result) { | 76 String stdoutOutput = result[0]; |
77 String stdoutOutput = result[0]; | 77 String stderrOutput = result[1]; |
78 String stderrOutput = result[1]; | |
79 | 78 |
80 Expect.equals(4, ">>> EOF STDERR".allMatches(stderrOutput).length); | 79 Expect.equals(4, ">>> EOF STDERR".allMatches(stderrOutput).length); |
81 Expect.equals(4, ">>>".allMatches(stderrOutput).length); | 80 Expect.equals(4, ">>>".allMatches(stderrOutput).length); |
82 | 81 |
83 Expect.equals(2, ">>> TEST OK".allMatches(stdoutOutput).length); | 82 Expect.equals(2, ">>> TEST OK".allMatches(stdoutOutput).length); |
84 Expect.equals(2, ">>> TEST FAIL".allMatches(stdoutOutput).length); | 83 Expect.equals(2, ">>> TEST FAIL".allMatches(stdoutOutput).length); |
85 Expect.equals(4, ">>>".allMatches(stdoutOutput).length); | 84 Expect.equals(4, ">>>".allMatches(stdoutOutput).length); |
86 }); | 85 }); |
87 } | 86 } |
88 | 87 |
89 void main() { | 88 void main() { |
90 var tmpDir; | 89 var tmpDir; |
91 asyncTest(() { | 90 asyncTest(() { |
92 return setup() | 91 return setup().then(launchDart2Js).then(runTests).whenComplete(cleanUp); |
93 .then(launchDart2Js) | |
94 .then(runTests) | |
95 .whenComplete(cleanUp); | |
96 }); | 92 }); |
97 } | 93 } |
OLD | NEW |