Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //#!/usr/bin/env dart | 1 //#!/usr/bin/env dart |
| 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * testrunner is a program to run Dart unit tests. Unlike $DART/tools/test.dart, | 7 * testrunner is a program to run Dart unit tests. Unlike $DART/tools/test.dart, |
| 8 * this program is intended for 3rd parties to be able to run unit tests in | 8 * this program is intended for 3rd parties to be able to run unit tests in |
| 9 * a batched fashion. As such, it adds some features and removes others. Some | 9 * a batched fashion. As such, it adds some features and removes others. Some |
| 10 * of the removed features are: | 10 * of the removed features are: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 * Layout file (re)generation can be done using `--regenerate`. This will | 63 * Layout file (re)generation can be done using `--regenerate`. This will |
| 64 * create or update the layout files (and implicitly pass the tests). | 64 * create or update the layout files (and implicitly pass the tests). |
| 65 * | 65 * |
| 66 * The wrapping and execution of test files is handled by test_pipeline.dart, | 66 * The wrapping and execution of test files is handled by test_pipeline.dart, |
| 67 * which is run in an isolate. The `--pipeline` argument can be used to | 67 * which is run in an isolate. The `--pipeline` argument can be used to |
| 68 * specify a different script for running a test file pipeline, allowing | 68 * specify a different script for running a test file pipeline, allowing |
| 69 * customization of the pipeline. | 69 * customization of the pipeline. |
| 70 */ | 70 */ |
| 71 | 71 |
| 72 // TODO - layout tests that use PNGs rather than DRT text render dumps. | 72 // TODO - layout tests that use PNGs rather than DRT text render dumps. |
| 73 #library('testrunner'); | 73 library testrunner; |
| 74 #import('dart:io'); | 74 import 'dart:io'; |
| 75 #import('dart:isolate'); | 75 import 'dart:isolate'; |
| 76 #import('dart:math'); | 76 import 'dart:math'; |
| 77 #import('../../pkg/args/lib/args.dart'); | 77 import '../../pkg/args/lib/args.dart'; |
| 78 | 78 |
| 79 #source('options.dart'); | 79 part 'options.dart'; |
| 80 #source('utils.dart'); | 80 part 'utils.dart'; |
| 81 | 81 |
| 82 /** The set of [PipelineRunner]s to execute. */ | 82 /** The set of [PipelineRunner]s to execute. */ |
| 83 List _tasks; | 83 List _tasks; |
| 84 | 84 |
| 85 /** The maximum number of pipelines that can run concurrently. */ | 85 /** The maximum number of pipelines that can run concurrently. */ |
| 86 int _maxTasks; | 86 int _maxTasks; |
| 87 | 87 |
| 88 /** The number of pipelines currently running. */ | 88 /** The number of pipelines currently running. */ |
| 89 int _numTasks; | 89 int _numTasks; |
| 90 | 90 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 */ | 181 */ |
| 182 void writelog(List messages, OutputStream out, OutputStream log, | 182 void writelog(List messages, OutputStream out, OutputStream log, |
| 183 bool includeVerbose, bool skipNonVerbose) { | 183 bool includeVerbose, bool skipNonVerbose) { |
| 184 for (var i = 0; i < messages.length; i++) { | 184 for (var i = 0; i < messages.length; i++) { |
| 185 var msg = messages[i]; | 185 var msg = messages[i]; |
| 186 if (msg.startsWith('###')) { | 186 if (msg.startsWith('###')) { |
| 187 if (!skipNonVerbose && out != null) { | 187 if (!skipNonVerbose && out != null) { |
| 188 out.writeString(msg.substring(3)); | 188 out.writeString(msg.substring(3)); |
| 189 out.writeString('\n'); | 189 out.writeString('\n'); |
| 190 } | 190 } |
| 191 } else if (msg.startsWith('CONSOLE MESSAGE:')) { | |
| 192 if (!skipNonVerbose && out != null) { | |
| 193 int idx = msg.indexOf('###'); | |
| 194 if (idx > 0) { | |
| 195 out.writeString(msg.substring(idx+3)); | |
|
Siggi Cherem (dart-lang)
2012/10/05 21:37:51
style nit: please add spaces around +
| |
| 196 out.writeString('\n'); | |
| 197 } | |
| 198 } | |
| 191 } else if (includeVerbose && log != null) { | 199 } else if (includeVerbose && log != null) { |
| 192 log.writeString(msg); | 200 log.writeString(msg); |
| 193 log.writeString('\n'); | 201 log.writeString('\n'); |
| 194 } | 202 } |
| 195 } | 203 } |
| 196 } | 204 } |
| 197 | 205 |
| 198 sanitizeConfig(Map config, ArgParser parser) { | 206 sanitizeConfig(Map config, ArgParser parser) { |
| 199 config['layout'] = config['layout-text'] || config['layout-pixel']; | 207 config['layout'] = config['layout-text'] || config['layout-pixel']; |
| 200 | 208 |
| 201 // TODO - check if next three are actually used. | 209 // TODO - check if next three are actually used. |
| 202 config['runInBrowser'] = (config['runtime'] != 'vm'); | 210 config['runInBrowser'] = (config['runtime'] != 'vm'); |
| 203 config['verbose'] = (config['log'] != 'none' && !config['list-groups']); | 211 config['verbose'] = (config['log'] != 'none' && !config['list-groups']); |
| 204 config['filtering'] = (config['include'].length > 0 || | 212 config['filtering'] = (config['include'].length > 0 || |
| 205 config['exclude'].length > 0); | 213 config['exclude'].length > 0); |
| 206 | 214 |
| 207 config['timeout'] = int.parse(config['timeout']); | 215 config['timeout'] = int.parse(config['timeout']); |
| 208 config['tasks'] = int.parse(config['tasks']); | 216 config['tasks'] = int.parse(config['tasks']); |
| 209 | 217 |
| 210 config['keep-files'] = (config['keep-files'] && | |
| 211 !(config['list-groups'] || config['list-tests'])); | |
| 212 | |
| 213 var dartsdk = config['dartsdk']; | 218 var dartsdk = config['dartsdk']; |
| 214 var pathSep = Platform.pathSeparator; | 219 var pathSep = Platform.pathSeparator; |
| 215 | 220 |
| 216 if (dartsdk != null) { | 221 if (dartsdk != null) { |
| 217 if (parser.getDefault('dart2js') == config['dart2js']) { | 222 if (parser.getDefault('dart2js') == config['dart2js']) { |
| 218 config['dart2js'] = | 223 config['dart2js'] = |
| 219 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js'; | 224 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js'; |
| 220 } | 225 } |
| 221 if (parser.getDefault('dart') == config['dart']) { | 226 if (parser.getDefault('dart') == config['dart']) { |
| 222 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart'; | 227 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 dirs.add('.'); // Use current working directory as default. | 274 dirs.add('.'); // Use current working directory as default. |
| 270 } | 275 } |
| 271 buildFileList(dirs, | 276 buildFileList(dirs, |
| 272 new RegExp(options['test-file-pattern']), options['recurse'], | 277 new RegExp(options['test-file-pattern']), options['recurse'], |
| 273 (f) => processTests(config, f)); | 278 (f) => processTests(config, f)); |
| 274 } | 279 } |
| 275 } | 280 } |
| 276 } | 281 } |
| 277 | 282 |
| 278 | 283 |
| OLD | NEW |