| 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 * This is a helper for run.sh. We try to run all of the Dart code in one | 6 * This is a helper for run.sh. We try to run all of the Dart code in one |
| 7 * instance of the Dart VM to reduce warm-up time. | 7 * instance of the Dart VM to reduce warm-up time. |
| 8 */ | 8 */ |
| 9 library web_ui.testing.render_test; | 9 library web_ui.testing.render_test; |
| 10 | 10 |
| 11 import 'dart:io'; | 11 import 'dart:io'; |
| 12 import 'dart:math' show min; | 12 import 'dart:math' show min; |
| 13 import 'package:pathos/path.dart' as path; | 13 import 'package:pathos/path.dart' as path; |
| 14 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 15 import 'package:web_ui/dwc.dart' as dwc; | 15 import 'package:web_ui/dwc.dart' as dwc; |
| 16 | 16 |
| 17 void renderTests(String baseDir, String inputDir, String expectedDir, | 17 void renderTests(String baseDir, String inputDir, String expectedDir, |
| 18 String outDir, {List<String> arguments, String script, String pattern, | 18 String outDir, {List<String> arguments, String script, String pattern, |
| 19 bool deleteDir: true}) { | 19 bool deleteDir: true}) { |
| 20 if (arguments == null) arguments = new Options().arguments; | 20 if (arguments == null) arguments = new Options().arguments; |
| 21 if (script == null) script = new Options().script; | 21 if (script == null) script = new Options().script; |
| 22 | 22 |
| 23 var filePattern = new RegExp(pattern != null ? pattern : '.'); | 23 var filePattern = new RegExp(pattern != null ? pattern |
| 24 : (arguments.length > 0 ? arguments.removeAt(0) : '.')); |
| 24 | 25 |
| 25 var scriptDir = path.absolute(path.dirname(script)); | 26 var scriptDir = path.absolute(path.dirname(script)); |
| 26 baseDir = path.join(scriptDir, baseDir); | 27 baseDir = path.join(scriptDir, baseDir); |
| 27 inputDir = path.join(scriptDir, inputDir); | 28 inputDir = path.join(scriptDir, inputDir); |
| 28 expectedDir = path.join(scriptDir, expectedDir); | 29 expectedDir = path.join(scriptDir, expectedDir); |
| 29 outDir = path.join(scriptDir, outDir); | 30 outDir = path.join(scriptDir, outDir); |
| 30 | 31 |
| 31 var paths = new Directory(inputDir).listSync() | 32 var paths = new Directory(inputDir).listSync() |
| 32 .where((f) => f is File).map((f) => f.path) | 33 .where((f) => f is File).map((f) => f.path) |
| 33 .where((p) => p.endsWith('_test.html') && filePattern.hasMatch(p)); | 34 .where((p) => p.endsWith('_test.html') && filePattern.hasMatch(p)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 var outPath = path.join(outDir, '$filename.txt'); | 87 var outPath = path.join(outDir, '$filename.txt'); |
| 87 var expectedPath = path.join(expectedDir, '$filename.txt'); | 88 var expectedPath = path.join(expectedDir, '$filename.txt'); |
| 88 new File(outPath).writeAsStringSync(output); | 89 new File(outPath).writeAsStringSync(output); |
| 89 var expected = new File(expectedPath).readAsStringSync(); | 90 var expected = new File(expectedPath).readAsStringSync(); |
| 90 expect(output, expected, | 91 expect(output, expected, |
| 91 reason: 'unexpected output for <$filename>'); | 92 reason: 'unexpected output for <$filename>'); |
| 92 }); | 93 }); |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 } | 96 } |
| OLD | NEW |