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

Side by Side Diff: utils/testrunner/dart_wrap_task.dart

Issue 10914049: Added support for layout render tests. These use expected values for the text render output from Du… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « utils/testrunner/configuration.dart ('k') | utils/testrunner/drt_task.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 * The DartWrapTask generates a Dart wrapper for a test file, that has a 6 * The DartWrapTask generates a Dart wrapper for a test file, that has a
7 * test Configuration customized for the options specified by the user. 7 * test Configuration customized for the options specified by the user.
8 */ 8 */
9 class DartWrapTask extends PipelineTask { 9 class DartWrapTask extends PipelineTask {
10 final String _sourceFileTemplate; 10 final String _sourceFileTemplate;
11 final String _tempDartFileTemplate; 11 final String _tempDartFileTemplate;
12 12
13 DartWrapTask(this._sourceFileTemplate, this._tempDartFileTemplate); 13 DartWrapTask(this._sourceFileTemplate, this._tempDartFileTemplate);
14 14
15 void execute(Path testfile, List stdout, List stderr, bool logging, 15 void execute(Path testfile, List stdout, List stderr, bool logging,
16 Function exitHandler) { 16 Function exitHandler) {
17 // Get the source test file and canonicalize the path. 17 // Get the source test file and canonicalize the path.
18 var sourceName = makePathAbsolute( 18 var sourceName = makePathAbsolute(
19 expandMacros(_sourceFileTemplate, testfile)); 19 expandMacros(_sourceFileTemplate, testfile));
20 // Get the destination file. 20 // Get the destination file.
21 var destFile = expandMacros(_tempDartFileTemplate, testfile); 21 var destFile = expandMacros(_tempDartFileTemplate, testfile);
22 22
23 var p = new Path(sourceName);
24 if (isLayoutRenderTest(sourceName) || config.generateRenders) {
25 makeLayoutTestWrapper(sourceName, destFile, p.filenameWithoutExtension);
26 exitHandler(0);
27 return;
28 }
29
23 // Working buffer for the Dart wrapper. 30 // Working buffer for the Dart wrapper.
24 StringBuffer sbuf = new StringBuffer(); 31 StringBuffer sbuf = new StringBuffer();
25 32
26 // Add the common header stuff. 33 // Add the common header stuff.
27 var p = new Path(sourceName);
28 sbuf.add(directives(p.filenameWithoutExtension, 34 sbuf.add(directives(p.filenameWithoutExtension,
29 config.unittestPath, 35 config.unittestPath,
30 sourceName)); 36 sourceName));
31 37
32 // Add the test configuration and determine the action function. 38 // Add the test configuration and determine the action function.
33 var action; 39 var action;
34 if (config.listTests) { 40 if (config.listTests) {
35 action = 'listTests'; 41 action = 'listTests';
36 sbuf.add(barebonesConfig()); 42 sbuf.add(barebonesConfig());
37 sbuf.add(listTestsFunction); 43 sbuf.add(listTestsFunction);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Save the Dart file. 99 // Save the Dart file.
94 createFile(destFile, sbuf.toString()); 100 createFile(destFile, sbuf.toString());
95 exitHandler(0); 101 exitHandler(0);
96 } 102 }
97 103
98 void cleanup(Path testfile, List stdout, List stderr, 104 void cleanup(Path testfile, List stdout, List stderr,
99 bool logging, bool keepFiles) { 105 bool logging, bool keepFiles) {
100 deleteFiles([_tempDartFileTemplate], testfile, logging, keepFiles, stdout); 106 deleteFiles([_tempDartFileTemplate], testfile, logging, keepFiles, stdout);
101 } 107 }
102 108
109 void makeLayoutTestWrapper(String sourceName, String destFile,
110 String libraryName) {
111 StringBuffer sbuf = new StringBuffer();
112 var cfg = config.unittestPath.
113 replaceAll('unittest.dart', 'html_layout_config.dart');
114 sbuf.add("""
115 #library('$libraryName');
116 #import('dart:math');
117 #import('dart:isolate');
118 #import('dart:html');
119 #import('${config.unittestPath}', prefix:'unittest');
120 #import('$cfg', prefix:'unittest');
121 #import('$sourceName', prefix: 'test');
122 """);
123 // Add the filter, if applicable.
124 if (config.filtering) {
125 if (config.includeFilter.length > 0) {
126 sbuf.add(filterTestFunction(config.includeFilter, 'true'));
127 } else {
128 sbuf.add(filterTestFunction(config.excludeFilter, 'false'));
129 }
130 }
131 sbuf.add("""
132 main() {
133 unittest.groupSep = '###';
134 unittest.useHtmlLayoutConfiguration();
135 unittest.group('', test.main);
136 ${config.filtering ? 'unittest.filterTests(filterTest);' : ''}
137 if (window.location.search == '') unittest.runTests();
138 }
139 """);
140 // Save the Dart file.
141 createFile(destFile, sbuf.toString());
142 }
143
103 String directives(String library, String unittest, String sourceName) { 144 String directives(String library, String unittest, String sourceName) {
104 return """ 145 return """
105 #library('$library'); 146 #library('$library');
106 #import('dart:math'); 147 #import('dart:math');
107 #import('dart:isolate'); 148 #import('dart:isolate');
108 #import('$unittest', prefix:'unittest'); 149 #import('$unittest', prefix:'unittest');
109 #import('$sourceName', prefix: 'test'); 150 #import('$sourceName', prefix: 'test');
110 """; 151 """;
111 } 152 }
112 153
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 runParentTest(); 475 runParentTest();
435 } 476 }
436 """; 477 """;
437 478
438 // Code for running all tests in the normal (non-isolate) way. 479 // Code for running all tests in the normal (non-isolate) way.
439 final String runTestsFunction = """ 480 final String runTestsFunction = """
440 runTests() { 481 runTests() {
441 unittest.runTests(); 482 unittest.runTests();
442 } 483 }
443 """; 484 """;
485
444 } 486 }
OLDNEW
« no previous file with comments | « utils/testrunner/configuration.dart ('k') | utils/testrunner/drt_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698