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 /** | 5 /** |
6 * Helper library to run tests in content_shell | 6 * Helper library to run tests in content_shell |
7 */ | 7 */ |
8 library polymer.testing.end2end; | 8 library polymer.testing.end2end; |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
11 import 'dart:math' show min; | |
12 import 'package:args/args.dart'; | 11 import 'package:args/args.dart'; |
13 import 'package:path/path.dart' as path; | 12 import 'package:path/path.dart' as path; |
14 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
15 import 'package:polymer/dwc.dart' as dwc; | 14 import 'package:polymer/dwc.dart' as dwc; |
16 | 15 |
17 | 16 |
18 /** | 17 /** |
19 * Compiles [testFile] with the web-ui compiler, and then runs the output as a | 18 * Compiles [testFile] with the web-ui compiler, and then runs the output as a |
20 * unit test in content_shell. | 19 * unit test in content_shell. |
21 */ | 20 */ |
(...skipping 28 matching lines...) Expand all Loading... |
50 var dir = new Directory(options.outDir); | 49 var dir = new Directory(options.outDir); |
51 if (dir.existsSync() && options.deleteDir) { | 50 if (dir.existsSync() && options.deleteDir) { |
52 print('Cleaning old output for ${path.normalize(options.outDir)}'); | 51 print('Cleaning old output for ${path.normalize(options.outDir)}'); |
53 dir.deleteSync(recursive: true); | 52 dir.deleteSync(recursive: true); |
54 } | 53 } |
55 dir.createSync(); | 54 dir.createSync(); |
56 | 55 |
57 for (var filePath in paths) { | 56 for (var filePath in paths) { |
58 var filename = path.basename(filePath); | 57 var filename = path.basename(filePath); |
59 test('compile $filename', () { | 58 test('compile $filename', () { |
60 var testArgs = ['-o', options.outDir, | 59 var testArgs = ['-o', options.outDir, '--basedir', options.baseDir] |
61 '--basedir', options.baseDir, '--no-css'] | |
62 ..addAll(options.compilerArgs) | 60 ..addAll(options.compilerArgs) |
63 ..add(filePath); | 61 ..add(filePath); |
64 expect(dwc.run(testArgs, printTime: false).then((res) { | 62 expect(dwc.run(testArgs, printTime: false).then((res) { |
65 expect(res.messages.length, 0, reason: res.messages.join('\n')); | 63 expect(res.messages.length, 0, reason: res.messages.join('\n')); |
66 }), completes); | 64 }), completes); |
67 }); | 65 }); |
68 } | 66 } |
69 | 67 |
70 var filenames = paths.map(path.basename).toList(); | 68 var filenames = paths.map(path.basename).toList(); |
71 // Sort files to match the order in which run.sh runs diff. | 69 // Sort files to match the order in which run.sh runs diff. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 219 |
222 try { | 220 try { |
223 var results = parser.parse(arguments); | 221 var results = parser.parse(arguments); |
224 if (results['help']) return showUsage(); | 222 if (results['help']) return showUsage(); |
225 return results; | 223 return results; |
226 } on FormatException catch (e) { | 224 } on FormatException catch (e) { |
227 print(e.message); | 225 print(e.message); |
228 return showUsage(); | 226 return showUsage(); |
229 } | 227 } |
230 } | 228 } |
OLD | NEW |