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 'package:path/path.dart' as path; | 12 import 'package:path/path.dart' as path; |
13 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
14 import 'package:web_ui/dwc.dart' as dwc; | 14 import 'package:web_ui/dwc.dart' as dwc; |
15 | 15 |
16 void renderTests(String baseDir, String inputDir, String expectedDir, | 16 void renderTests(String baseDir, String inputDir, String expectedDir, |
17 String outDir, {List<String> arguments, String script, String pattern, | 17 String outDir, {List<String> arguments, String script, String pattern, |
18 bool deleteDir: true}) { | 18 bool deleteDir: true}) { |
19 if (arguments == null) arguments = []; | 19 if (arguments == null) arguments = []; |
20 if (script == null) script = Platform.script.toString(); | 20 if (script == null) script = Platform.script.path; |
21 | 21 |
22 var filePattern = new RegExp(pattern != null ? pattern | 22 var filePattern = new RegExp(pattern != null ? pattern |
23 : (arguments.length > 0 ? arguments.removeAt(0) : '.')); | 23 : (arguments.length > 0 ? arguments.removeAt(0) : '.')); |
24 | 24 |
25 var scriptDir = path.absolute(path.dirname(script)); | 25 var scriptDir = path.absolute(path.dirname(script)); |
26 baseDir = path.join(scriptDir, baseDir); | 26 baseDir = path.join(scriptDir, baseDir); |
27 inputDir = path.join(scriptDir, inputDir); | 27 inputDir = path.join(scriptDir, inputDir); |
28 expectedDir = path.join(scriptDir, expectedDir); | 28 expectedDir = path.join(scriptDir, expectedDir); |
29 outDir = path.join(scriptDir, outDir); | 29 outDir = path.join(scriptDir, outDir); |
30 | 30 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 var outPath = path.join(outDir, '$filename.txt'); | 86 var outPath = path.join(outDir, '$filename.txt'); |
87 var expectedPath = path.join(expectedDir, '$filename.txt'); | 87 var expectedPath = path.join(expectedDir, '$filename.txt'); |
88 new File(outPath).writeAsStringSync(output); | 88 new File(outPath).writeAsStringSync(output); |
89 var expected = new File(expectedPath).readAsStringSync(); | 89 var expected = new File(expectedPath).readAsStringSync(); |
90 expect(output, expected, | 90 expect(output, expected, |
91 reason: 'unexpected output for <$filename>'); | 91 reason: 'unexpected output for <$filename>'); |
92 }); | 92 }); |
93 } | 93 } |
94 } | 94 } |
95 } | 95 } |
OLD | NEW |