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

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

Issue 20863002: Introduce boot.js: this finally makes it possible to load and run Todomvc (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
Patch Set: Created 7 years, 4 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
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 * 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';
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 var dir = new Directory(options.outDir); 50 var dir = new Directory(options.outDir);
51 if (dir.existsSync() && options.deleteDir) { 51 if (dir.existsSync() && options.deleteDir) {
52 print('Cleaning old output for ${path.normalize(options.outDir)}'); 52 print('Cleaning old output for ${path.normalize(options.outDir)}');
53 dir.deleteSync(recursive: true); 53 dir.deleteSync(recursive: true);
54 } 54 }
55 dir.createSync(); 55 dir.createSync();
56 56
57 for (var filePath in paths) { 57 for (var filePath in paths) {
58 var filename = path.basename(filePath); 58 var filename = path.basename(filePath);
59 test('compile $filename', () { 59 test('compile $filename', () {
60 var testArgs = ['-o', options.outDir, '--basedir', options.baseDir] 60 var testArgs = ['-o', options.outDir,
61 '--basedir', options.baseDir, '--no-css']
61 ..addAll(options.compilerArgs) 62 ..addAll(options.compilerArgs)
62 ..add(filePath); 63 ..add(filePath);
63 expect(dwc.run(testArgs, printTime: false).then((res) { 64 expect(dwc.run(testArgs, printTime: false).then((res) {
64 expect(res.messages.length, 0, reason: res.messages.join('\n')); 65 expect(res.messages.length, 0, reason: res.messages.join('\n'));
65 }), completes); 66 }), completes);
66 }); 67 });
67 } 68 }
68 69
69 var filenames = paths.map(path.basename).toList(); 70 var filenames = paths.map(path.basename).toList();
70 // Sort files to match the order in which run.sh runs diff. 71 // Sort files to match the order in which run.sh runs diff.
71 filenames.sort(); 72 filenames.sort();
72 73
73 // Get the path from "input" relative to "baseDir" 74 // Get the path from "input" relative to "baseDir"
74 var relativeToBase = path.relative(options.inputDir, from: options.baseDir); 75 var relativeToBase = path.relative(options.inputDir, from: options.baseDir);
75 var finalOutDir = path.join(options.outDir, relativeToBase); 76 var finalOutDir = path.join(options.outDir, relativeToBase);
76 77
77 runTests(String search) { 78 runTests(String search) {
78 var outs; 79 var output;
79 80
80 test('content_shell run $search', () { 81 for (var filename in filenames) {
Siggi Cherem (dart-lang) 2013/07/30 23:32:04 I'm splitting each content_shell run to be separat
81 var args = ['--dump-render-tree']; 82 test('content_shell run $filename$search', () {
82 args.addAll(filenames.map((name) => 'file://$finalOutDir/$name$search')); 83 var args = ['--dump-render-tree',
83 var env = {'DART_FLAGS': '--checked'}; 84 'file://$finalOutDir/$filename$search'];
84 expect(Process.run('content_shell', args, environment: env).then((res) { 85 var env = {'DART_FLAGS': '--checked'};
85 expect(res.exitCode, 0, reason: 'content_shell exit code: ' 86 expect(Process.run('content_shell', args, environment: env).then((res) {
86 '${res.exitCode}. Contents of stderr: \n${res.stderr}'); 87 expect(res.exitCode, 0, reason: 'content_shell exit code: '
87 outs = res.stdout.split('#EOF\n') 88 '${res.exitCode}. Contents of stderr: \n${res.stderr}');
88 .where((s) => !s.trim().isEmpty).toList(); 89 var outs = res.stdout.split('#EOF\n')
89 expect(outs.length, filenames.length); 90 .where((s) => !s.trim().isEmpty).toList();
90 }), completes); 91 expect(outs.length, 1);
91 }); 92 output = outs.first;
93 }), completes);
94 });
92 95
93 for (int i = 0; i < filenames.length; i++) {
94 var filename = filenames[i];
95 // TODO(sigmund): remove this extra variable dartbug.com/8698
96 int j = i;
97 test('verify $filename $search', () { 96 test('verify $filename $search', () {
98 expect(outs, isNotNull, reason: 97 expect(output, isNotNull, reason:
99 'Output not available, maybe content_shell failed to run.'); 98 'Output not available, maybe content_shell failed to run.');
100 var output = outs[j];
101 var outPath = path.join(options.outDir, '$filename.txt'); 99 var outPath = path.join(options.outDir, '$filename.txt');
102 new File(outPath).writeAsStringSync(output); 100 new File(outPath).writeAsStringSync(output);
103 if (options.isRenderTest) { 101 if (options.isRenderTest) {
104 var expectedPath = path.join(options.expectedDir, '$filename.txt'); 102 var expectedPath = path.join(options.expectedDir, '$filename.txt');
105 var expected = new File(expectedPath).readAsStringSync(); 103 var expected = new File(expectedPath).readAsStringSync();
106 expect(output, expected, reason: 'unexpected output for <$filename>'); 104 expect(output, expected, reason: 'unexpected output for <$filename>');
107 } else { 105 } else {
108 bool passes = matches( 106 bool passes = matches(
109 new RegExp('All .* tests passed')).matches(output, {}); 107 new RegExp('All .* tests passed')).matches(output, {});
110 expect(passes, true, reason: 'unit test failed:\n$output'); 108 expect(passes, true, reason: 'unit test failed:\n$output');
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 169
172 factory _TestOptions(String baseDir, String inputDir, String expectedDir, 170 factory _TestOptions(String baseDir, String inputDir, String expectedDir,
173 String outDir, {List<String> arguments, String script, String pattern, 171 String outDir, {List<String> arguments, String script, String pattern,
174 bool deleteDir: true}) { 172 bool deleteDir: true}) {
175 if (arguments == null) arguments = new Options().arguments; 173 if (arguments == null) arguments = new Options().arguments;
176 if (script == null) script = new Options().script; 174 if (script == null) script = new Options().script;
177 175
178 var args = _parseArgs(arguments, script); 176 var args = _parseArgs(arguments, script);
179 if (args == null) return null; 177 if (args == null) return null;
180 var compilerArgs = args.rest; 178 var compilerArgs = args.rest;
181 var filePattern = new RegExp(pattern != null ? pattern 179 var filePattern;
182 : (compilerArgs.length > 0 ? compilerArgs.removeAt(0) : '.')); 180 if (pattern != null) {
181 filePattern = new RegExp(pattern);
182 } else if (compilerArgs.length > 0) {
183 filePattern = new RegExp(compilerArgs[0]);
184 compilerArgs = compilerArgs.sublist(1);
185 } else {
186 filePattern = new RegExp('.');
187 }
183 188
184 var scriptDir = path.absolute(path.dirname(script)); 189 var scriptDir = path.absolute(path.dirname(script));
185 baseDir = path.join(scriptDir, baseDir); 190 baseDir = path.join(scriptDir, baseDir);
186 inputDir = path.join(scriptDir, inputDir); 191 inputDir = path.join(scriptDir, inputDir);
187 outDir = path.join(scriptDir, outDir); 192 outDir = path.join(scriptDir, outDir);
188 if (expectedDir != null) { 193 if (expectedDir != null) {
189 expectedDir = path.join(scriptDir, expectedDir); 194 expectedDir = path.join(scriptDir, expectedDir);
190 } 195 }
191 196
192 return new _TestOptions._(baseDir, inputDir, expectedDir, outDir, deleteDir, 197 return new _TestOptions._(baseDir, inputDir, expectedDir, outDir, deleteDir,
(...skipping 23 matching lines...) Expand all
216 221
217 try { 222 try {
218 var results = parser.parse(arguments); 223 var results = parser.parse(arguments);
219 if (results['help']) return showUsage(); 224 if (results['help']) return showUsage();
220 return results; 225 return results;
221 } on FormatException catch (e) { 226 } on FormatException catch (e) {
222 print(e.message); 227 print(e.message);
223 return showUsage(); 228 return showUsage();
224 } 229 }
225 } 230 }
OLDNEW
« no previous file with comments | « lib/src/observable_transform.dart ('k') | pubspec.yaml » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698