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

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

Issue 11033042: Change imports etc to new syntax. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
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 /** The default pipeline code for running a test file. */ 5 /** The default pipeline code for running a test file. */
6 #library('pipeline'); 6 library pipeline;
7 #import('dart:isolate'); 7 import 'dart:isolate';
8 #import('dart:io'); 8 import 'dart:io';
9 #source('pipeline_utils.dart'); 9 part 'pipeline_utils.dart';
10 10
11 /** 11 /**
12 * The configuration passed in to the pipeline runner; this essentially 12 * The configuration passed in to the pipeline runner; this essentially
13 * contains all the command line arguments passded to testrunner plus some 13 * contains all the command line arguments passded to testrunner plus some
14 * synthesized ones. 14 * synthesized ones.
15 */ 15 */
16 Map config; 16 Map config;
17 17
18 /** Paths to the various generated temporary files. */ 18 /** Paths to the various generated temporary files. */
19 String tempDartFile = null; 19 String tempDartFile = null;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 createTempName(tmpDir, testFile, '-child.js'); 71 createTempName(tmpDir, testFile, '-child.js');
72 } 72 }
73 } 73 }
74 } 74 }
75 75
76 // Create the test controller Dart wrapper. 76 // Create the test controller Dart wrapper.
77 var directives, extras; 77 var directives, extras;
78 78
79 if (config["layout"]) { 79 if (config["layout"]) {
80 directives = ''' 80 directives = '''
81 #import('dart:uri'); 81 import 'dart:uri';
82 #import('dart:io'); 82 import 'dart:io';
83 #import('dart:math'); 83 import 'dart:math';
84 #source('${config["runnerDir"]}/layout_test_controller.dart'); 84 part '${config["runnerDir"]}/layout_test_controller.dart';
85 '''; 85 ''';
86 extras = ''' 86 extras = '''
87 sourceDir = '${config["expectedDirectory"]}'; 87 sourceDir = '${config["expectedDirectory"]}';
88 baseUrl = 'file://$tempHtmlFile'; 88 baseUrl = 'file://$tempHtmlFile';
89 tprint = (msg) => print('###\$msg'); 89 tprint = (msg) => print('###\$msg');
90 notifyDone = (e) => exit(e); 90 notifyDone = (e) => exit(e);
91 '''; 91 ''';
92 } else if (config["runtime"] == "vm") { 92 } else if (config["runtime"] == "vm") {
93 directives = ''' 93 directives = '''
94 #import('dart:io'); 94 import 'dart:io';
95 #import('dart:isolate'); 95 import 'dart:isolate';
96 #import('${config["unittest"]}', prefix:'unittest'); 96 import '${config["unittest"]}' as unittest;
97 #import('${config["testfile"]}', prefix: 'test'); 97 import '${config["testfile"]}' as test;
98 #source('${config["runnerDir"]}/standard_test_runner.dart'); 98 part '${config["runnerDir"]}/standard_test_runner.dart';
99 '''; 99 ''';
100 extras = ''' 100 extras = '''
101 includeFilters = ${config["include"]}; 101 includeFilters = ${config["include"]};
102 excludeFilters = ${config["exclude"]}; 102 excludeFilters = ${config["exclude"]};
103 tprint = (msg) => print('###\$msg'); 103 tprint = (msg) => print('###\$msg');
104 notifyDone = (e) {}; 104 notifyDone = (e) {};
105 '''; 105 ''';
106 } else { 106 } else {
107 directives = ''' 107 directives = '''
108 #import('dart:html'); 108 import 'dart:html';
109 #import('dart:isolate'); 109 import 'dart:isolate';
110 #import('${config["unittest"]}', prefix:'unittest'); 110 import '${config["unittest"]}' as unittest;
111 #import('${config["testfile"]}', prefix: 'test'); 111 import '${config["testfile"]}' as test;
112 #source('${config["runnerDir"]}/standard_test_runner.dart'); 112 part '${config["runnerDir"]}/standard_test_runner.dart';
113 '''; 113 ''';
114 extras = ''' 114 extras = '''
115 includeFilters = ${config["include"]}; 115 includeFilters = ${config["include"]};
116 excludeFilters = ${config["exclude"]}; 116 excludeFilters = ${config["exclude"]};
117 tprint = (msg) => query('#console').addText('###\$msg\\n'); 117 tprint = (msg) => query('#console').addText('###\$msg\\n');
118 notifyDone = (e) => window.postMessage('done', '*'); 118 notifyDone = (e) => window.postMessage('done', '*');
119 '''; 119 ''';
120 } 120 }
121 121
122 var action = 'process(test.main, unittest.runTests)'; 122 var action = 'process(test.main, unittest.runTests)';
123 if (config["layout-text"]) { 123 if (config["layout-text"]) {
124 action = 'runTextLayoutTests()'; 124 action = 'runTextLayoutTests()';
125 } else if (config["layout-pixel"]) { 125 } else if (config["layout-pixel"]) {
126 action = 'runPixelLayoutTests()'; 126 action = 'runPixelLayoutTests()';
127 } else if (config["list-tests"]) { 127 } else if (config["list-tests"]) {
128 action = 'process(test.main, listTests)'; 128 action = 'process(test.main, listTests)';
129 } else if (config["list-groups"]) { 129 } else if (config["list-groups"]) {
130 action = 'process(test.main, listGroups)'; 130 action = 'process(test.main, listGroups)';
131 } else if (config["isolate"]) { 131 } else if (config["isolate"]) {
132 action = 'process(test.main, runIsolateTests)'; 132 action = 'process(test.main, runIsolateTests)';
133 } 133 }
134 134
135 logMessage('Creating $tempDartFile'); 135 logMessage('Creating $tempDartFile');
136 writeFile(tempDartFile, ''' 136 writeFile(tempDartFile, '''
137 #library('test_controller'); 137 library test_controller;
138 $directives 138 $directives
139 139
140 main() { 140 main() {
141 immediate = ${config["immediate"]}; 141 immediate = ${config["immediate"]};
142 includeTime = ${config["time"]}; 142 includeTime = ${config["time"]};
143 passFormat = '${config["pass-format"]}'; 143 passFormat = '${config["pass-format"]}';
144 failFormat = '${config["fail-format"]}'; 144 failFormat = '${config["fail-format"]}';
145 errorFormat = '${config["error-format"]}'; 145 errorFormat = '${config["error-format"]}';
146 listFormat = '${config["list-format"]}'; 146 listFormat = '${config["list-format"]}';
147 regenerate = ${config["regenerate"]}; 147 regenerate = ${config["regenerate"]};
148 summarize = ${config["summary"]}; 148 summarize = ${config["summary"]};
149 testfile = '$testFile'; 149 testfile = '$testFile';
150 drt = '${config["drt"]}'; 150 drt = '${config["drt"]}';
151 $extras 151 $extras
152 $action; 152 $action;
153 } 153 }
154 '''); 154 ''');
155 155
156 // Create the child wrapper for layout tests. 156 // Create the child wrapper for layout tests.
157 if (config["layout"]) { 157 if (config["layout"]) {
158 logMessage('Creating $tempChildDartFile'); 158 logMessage('Creating $tempChildDartFile');
159 writeFile(tempChildDartFile, ''' 159 writeFile(tempChildDartFile, '''
160 #library('layout_test'); 160 library layout_test;
161 #import('dart:math'); 161 import 'dart:math';
162 #import('dart:isolate'); 162 import 'dart:isolate';
163 #import('dart:html'); 163 import 'dart:html';
164 #import('dart:uri'); 164 import 'dart:uri';
165 #import('${config["unittest"]}', prefix:'unittest'); 165 import '${config["unittest"]}' as 'unittest' ;
166 #import('$testFile', prefix: 'test'); 166 import '$testFile', prefix: 'test' ;
167 #source('${config["runnerDir"]}/layout_test_runner.dart'); 167 part '${config["runnerDir"]}/layout_test_runner.dart';
168 168
169 main() { 169 main() {
170 includeFilters = ${config["include"]}; 170 includeFilters = ${config["include"]};
171 excludeFilters = ${config["exclude"]}; 171 excludeFilters = ${config["exclude"]};
172 runTests(test.main); 172 runTests(test.main);
173 } 173 }
174 '''); 174 ''');
175 } 175 }
176 176
177 177
178 // Create the HTML wrapper and compile to Javascript if necessary. 178 // Create the HTML wrapper and compile to Javascript if necessary.
179 var isJavascript = config["runtime"] == 'drt-js'; 179 var isJavascript = config["runtime"] == 'drt-js';
180 if (config["runtime"] == 'drt-dart' || isJavascript) { 180 if (config["runtime"] == 'drt-dart' || isJavascript) {
181 var bodyElements, runAsText; 181 var bodyElements, runAsText;
182 182
183 if (config["layout"]) { 183 if (config["layout"]) {
184 sourceFile = tempChildDartFile; 184 sourceFile = tempChildDartFile;
185 scriptFile = isJavascript ? tempChildJsFile : tempChildDartFile; 185 scriptFile = isJavascript ? tempChildJsFile : tempChildDartFile;
186 bodyElements = ''; 186 bodyElements = '';
187 } else { 187 } else {
188 sourceFile = tempDartFile; 188 sourceFile = tempDartFile;
189 scriptFile = isJavascript ? tempJsFile : tempDartFile; 189 scriptFile = isJavascript ? tempJsFile : tempDartFile;
190 bodyElements = '<div id="container"></div><pre id="console"></pre>'; 190 bodyElements = '<div id="container"></div><pre id="console"></pre>';
191 runAsText = "window.testRunner.dumpAsText();"; 191 runAsText = "window.testRunner.dumpAsText();";
192 } 192 }
193 scriptType = isJavascript ? 'text/javascript' : 'application/dart'; 193 scriptType = isJavascript ? 'text/javascript' : 'application/dart';
194 194
195 if (config["runtime"] == 'drt-dart' || isJavascript) { 195 if (config["runtime"] == 'drt-dart' || isJavascript) {
196 logMessage('Creating $tempHtmlFile'); 196 logMessage('Creating $tempHtmlFile');
197 writeFile(tempHtmlFile, ''' 197 writeFile(tempHtmlFile, '''
198 <!DOCTYPE html> 198 <!DOCTYPE html>
199 <html> 199 <html>
200 <head> 200 <head>
201 <meta charset="utf-8"> 201 <meta charset="utf-8">
202 <title>$testFile</title> 202 <title>$testFile</title>
203 <link rel="stylesheet" href="${config["runnerDir"]}/testrunner.css"> 203 <link rel="stylesheet" href="${config["runnerDir"]}/testrunner.css">
204 <script type='text/javascript'> 204 <script type='text/javascript'>
205 if (window.testRunner) { 205 if (window.testRunner) {
206 function handleMessage(m) { 206 function handleMessage(m) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 /** 277 /**
278 * Final stage of the pipeline - clean up generated files and notify 278 * Final stage of the pipeline - clean up generated files and notify
279 * the originator that started the isolate. 279 * the originator that started the isolate.
280 */ 280 */
281 cleanupStage(exitcode) { 281 cleanupStage(exitcode) {
282 if (config["server"]) { // Stop the HTTP server. 282 if (config["server"]) { // Stop the HTTP server.
283 stopProcess(serverId); 283 stopProcess(serverId);
284 } 284 }
285 285
286 if (!config["keep_files"]) { // Remove the temporary files. 286 if (!config["keep-files"]) { // Remove the temporary files.
287 cleanup(tempDartFile); 287 cleanup(tempDartFile);
288 cleanup(tempHtmlFile); 288 cleanup(tempHtmlFile);
289 cleanup(tempJsFile); 289 cleanup(tempJsFile);
290 cleanup(tempChildDartFile); 290 cleanup(tempChildDartFile);
291 cleanup(tempChildJsFile); 291 cleanup(tempChildJsFile);
292 } 292 }
293 completePipeline(exitcode); 293 completePipeline(exitcode);
294 } 294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698