Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: lib/testing/render_test.dart

Issue 18581007: Address comments directly in master, adjust for new sdk html fields. (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/web_ui.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> args, String script, String pattern, 18 String outDir, {List<String> arguments, String script, String pattern,
19 bool deleteDir = true]) { 19 bool deleteDir: true}) {
20 if (args == null) args = 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 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
31 var paths = new Directory(inputDir).listSync() 31 var paths = new Directory(inputDir).listSync()
32 .where((f) => f is File).map((f) => f.path) 32 .where((f) => f is File).map((f) => f.path)
33 .where((p) => p.endsWith('_test.html') && filePattern.hasMatch(p)); 33 .where((p) => p.endsWith('_test.html') && filePattern.hasMatch(p));
34 34
35 // First clear the output folder. Otherwise we can miss bugs when we fail to 35 // First clear the output folder. Otherwise we can miss bugs when we fail to
36 // generate a file. 36 // generate a file.
37 var dir = new Directory(outDir); 37 var dir = new Directory(outDir);
38 if (dir.existsSync() && deleteDir) { 38 if (dir.existsSync() && deleteDir) {
39 print('Cleaning old output for ${path.normalize(outDir)}'); 39 print('Cleaning old output for ${path.normalize(outDir)}');
40 dir.deleteSync(recursive: true); 40 dir.deleteSync(recursive: true);
41 } 41 }
42 dir.createSync(); 42 dir.createSync();
43 43
44 args.addAll(['-o', outDir, '--basedir', baseDir]); 44 arguments.addAll(['-o', outDir, '--basedir', baseDir]);
45 for (var filePath in paths) { 45 for (var filePath in paths) {
46 var filename = path.basename(filePath); 46 var filename = path.basename(filePath);
47 test('compile $filename', () { 47 test('compile $filename', () {
48 var testArgs = args.toList(); 48 var testArgs = arguments.toList();
49 testArgs.add(filePath); 49 testArgs.add(filePath);
50 expect(dwc.run(testArgs, printTime: false).then((res) { 50 expect(dwc.run(testArgs, printTime: false).then((res) {
51 expect(res.messages.length, 0, reason: res.messages.join('\n')); 51 expect(res.messages.length, 0, reason: res.messages.join('\n'));
52 }), completes); 52 }), completes);
53 }); 53 });
54 } 54 }
55 55
56 if (!paths.isEmpty) { 56 if (!paths.isEmpty) {
57 var filenames = paths.map(path.basename).toList(); 57 var filenames = paths.map(path.basename).toList();
58 // Sort files to match the order in which run.sh runs diff. 58 // Sort files to match the order in which run.sh runs diff.
(...skipping 27 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « no previous file | lib/web_ui.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698