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

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

Issue 10977069: New testrunner that runs the test pipleine in an isolate. (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 following set of variables should be set by the caller that 5 // The following set of variables should be set by the caller that
6 // #sources this file. 6 // #sources this file.
7 /** Whether to include elapsed time. */ 7 /** Whether to include elapsed time. */
8 bool includeTime; 8 bool includeTime;
9 9
10 /** Path to DRT executable. */ 10 /** Path to DRT executable. */
11 String drt; 11 String drt;
12 12
13 /** Whether to regenerate layout test files. */ 13 /** Whether to regenerate layout test files. */
14 bool regenerate; 14 bool regenerate;
15 15
16 /** Whether to output test summary. */ 16 /** Whether to output test summary. */
17 bool summarize; 17 bool summarize;
18 18
19 /** Whether to print results immediately as they come in. */
20 bool immediate;
21
19 /** Format strings to use for test result messages. */ 22 /** Format strings to use for test result messages. */
20 String passFormat, failFormat, errorFormat, listFormat; 23 String passFormat, failFormat, errorFormat, listFormat;
21 24
22 /** Location of the running test file. */ 25 /** Location of the running test file. */
23 String sourceDir; 26 String sourceDir;
24 27
25 /** Path of the running test file. */ 28 /** Path of the running test file. */
26 String testfile; 29 String testfile;
27 30
28 /** URL of the child test file. */ 31 /** URL of the child test file. */
29 String baseUrl; 32 String baseUrl;
30 33
34 /** The print function to use. */
35 Function tprint;
36
37 /** A callback function to notify the caller we are done. */
38 Function notifyDone;
39
31 // Variable below here are local to this file. 40 // Variable below here are local to this file.
32 var passCount = 0, failCount = 0, errorCount = 0; 41 var passCount = 0, failCount = 0, errorCount = 0;
33 Date start; 42 Date start;
34 43
35 void tprint(msg) {
36 print('###$msg');
37 }
38
39 class Macros { 44 class Macros {
40 static const String testTime = '<TIME>'; 45 static const String testTime = '<TIME>';
41 static const String testfile = '<FILENAME>'; 46 static const String testfile = '<FILENAME>';
42 static const String testGroup = '<GROUPNAME>'; 47 static const String testGroup = '<GROUPNAME>';
43 static const String testDescription = '<TESTNAME>'; 48 static const String testDescription = '<TESTNAME>';
44 static const String testMessage = '<MESSAGE>'; 49 static const String testMessage = '<MESSAGE>';
45 static const String testStacktrace = '<STACK>'; 50 static const String testStacktrace = '<STACK>';
46 } 51 }
47 52
48 String formatMessage(filename, groupname, 53 String formatMessage(filename, groupname,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 tprint('$testFile: Top-level uncaught error: $uncaughtError'); 111 tprint('$testFile: Top-level uncaught error: $uncaughtError');
107 } 112 }
108 tprint('$testFile: $passed PASSED, $failed FAILED, $errors ERRORS'); 113 tprint('$testFile: $passed PASSED, $failed FAILED, $errors ERRORS');
109 } 114 }
110 } 115 }
111 116
112 complete() { 117 complete() {
113 if (summarize) { 118 if (summarize) {
114 printSummary(testfile, passCount, failCount, errorCount); 119 printSummary(testfile, passCount, failCount, errorCount);
115 } 120 }
116 exit(failCount > 0 ? -1 : 0); 121 notifyDone(failCount > 0 ? -1 : 0);
117 } 122 }
118 123
119 runTextLayoutTest(testNum) { 124 runTextLayoutTest(testNum) {
120 var url = '$baseUrl?test=$testNum'; 125 var url = '$baseUrl?test=$testNum';
121 var stdout = new List(); 126 var stdout = new List();
122 start = new Date.now(); 127 start = new Date.now();
123 var process = Process.start(drt, [url]); 128 var process = Process.start(drt, [url]);
124 StringInputStream stdoutStringStream = new StringInputStream(process.stdout); 129 StringInputStream stdoutStringStream = new StringInputStream(process.stdout);
125 stdoutStringStream.onLine = () { 130 stdoutStringStream.onLine = () {
126 if (stdoutStringStream.closed) return; 131 if (stdoutStringStream.closed) return;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 break; 280 break;
276 } 281 }
277 pos = idx; 282 pos = idx;
278 } 283 }
279 if (label != null) { 284 if (label != null) {
280 if (!done) error(start, label, 'Failed to parse output'); 285 if (!done) error(start, label, 'Failed to parse output');
281 runPixelLayoutTest(testNum + 1); 286 runPixelLayoutTest(testNum + 1);
282 } 287 }
283 }; 288 };
284 } 289 }
290
291 void init() {
292 // Get the name of the directory that has the expectation files
293 // (by stripping .dart suffix from test file path).
294 // Create it if it does not exist.
295 sourceDir = testfile.substring(0, testfile.length - 5);
296 if (regenerate) {
297 var d = new Directory(sourceDir);
298 if (!d.existsSync()) {
299 d.createSync();
300 }
301 }
302 }
303
304 void runPixelLayoutTests() {
305 init();
306 runPixelLayoutTest(0);
307 }
308
309 void runTextLayoutTests() {
310 init();
311 runTextLayoutTest(0);
312 }
313
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698