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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 void sanitizeConfig(Map config, ArgParser parser) { | 332 void sanitizeConfig(Map config, ArgParser parser) { |
333 config['layout'] = config['layout-text'] || config['layout-pixel']; | 333 config['layout'] = config['layout-text'] || config['layout-pixel']; |
334 config['verbose'] = (config['log'] != 'none' && !config['list-groups']); | 334 config['verbose'] = (config['log'] != 'none' && !config['list-groups']); |
335 config['timeout'] = int.parse(config['timeout']); | 335 config['timeout'] = int.parse(config['timeout']); |
336 config['tasks'] = int.parse(config['tasks']); | 336 config['tasks'] = int.parse(config['tasks']); |
337 | 337 |
338 var dartsdk = config['dartsdk']; | 338 var dartsdk = config['dartsdk']; |
339 var pathSep = Platform.pathSeparator; | 339 var pathSep = Platform.pathSeparator; |
340 | 340 |
341 if (dartsdk == null) { | 341 if (dartsdk == null) { |
342 var opt = new Options(); | 342 var runner = Platform.executable; |
343 var runner = opt.executable; | |
344 var idx = runner.indexOf('dart-sdk'); | 343 var idx = runner.indexOf('dart-sdk'); |
345 if (idx < 0) { | 344 if (idx < 0) { |
346 print("Please use --dartsdk option or run using the dart executable " | 345 print("Please use --dartsdk option or run using the dart executable " |
347 "from the Dart SDK"); | 346 "from the Dart SDK"); |
348 exit(0); | 347 exit(0); |
349 } | 348 } |
350 dartsdk = runner.substring(0, idx); | 349 dartsdk = runner.substring(0, idx); |
351 } | 350 } |
352 if (Platform.operatingSystem == 'macos') { | 351 if (Platform.operatingSystem == 'macos') { |
353 config['dart2js'] = | 352 config['dart2js'] = |
354 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js'; | 353 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js'; |
355 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart'; | 354 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart'; |
356 config['pub'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}pub'; | 355 config['pub'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}pub'; |
357 config['drt'] = | 356 config['drt'] = |
358 '$dartsdk/chromium/Content Shell.app/Contents/MacOS/Content Shell'; | 357 '$dartsdk/chromium/Content Shell.app/Contents/MacOS/Content Shell'; |
359 } else if (Platform.operatingSystem == 'linux') { | 358 } else if (Platform.operatingSystem == 'linux') { |
360 config['dart2js'] = | 359 config['dart2js'] = |
361 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js'; | 360 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js'; |
362 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart'; | 361 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart'; |
363 config['pub'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}pub'; | 362 config['pub'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}pub'; |
364 config['drt'] = '$dartsdk${pathSep}chromium${pathSep}content_shell'; | 363 config['drt'] = '$dartsdk${pathSep}chromium${pathSep}content_shell'; |
365 } else { | 364 } else { |
366 config['dart2js'] = | 365 config['dart2js'] = |
367 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js.bat'; | 366 '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart2js.bat'; |
368 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart.exe'
; | 367 config['dart'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}dart.exe'
; |
369 config['pub'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}pub.bat'; | 368 config['pub'] = '$dartsdk${pathSep}dart-sdk${pathSep}bin${pathSep}pub.bat'; |
370 config['drt'] = '$dartsdk${pathSep}chromium${pathSep}content_shell.exe'; | 369 config['drt'] = '$dartsdk${pathSep}chromium${pathSep}content_shell.exe'; |
371 } | 370 } |
372 | 371 |
373 for (var prog in [ 'drt', 'dart', 'pub', 'dart2js' ]) { | 372 for (var prog in [ 'drt', 'dart', 'pub', 'dart2js' ]) { |
374 config[prog] = makePathAbsolute(config[prog]); | 373 config[prog] = makePathAbsolute(config[prog]); |
375 } | 374 } |
376 config['runnerDir'] = runnerDirectory; | 375 config['runnerDir'] = runnerDirectory; |
377 config['include'] = normalizeFilter(config['include']); | 376 config['include'] = normalizeFilter(config['include']); |
378 config['exclude'] = normalizeFilter(config['exclude']); | 377 config['exclude'] = normalizeFilter(config['exclude']); |
379 } | 378 } |
380 | 379 |
381 main() { | 380 main(List<String> arguments) { |
382 var optionsParser = getOptionParser(); | 381 var optionsParser = getOptionParser(); |
383 var options = loadConfiguration(optionsParser); | 382 var options = loadConfiguration(optionsParser, arguments); |
384 if (isSane(options)) { | 383 if (isSane(options)) { |
385 if (options['list-options']) { | 384 if (options['list-options']) { |
386 printOptions(optionsParser, options, false, stdout); | 385 printOptions(optionsParser, options, false, stdout); |
387 } else if (options['list-all-options']) { | 386 } else if (options['list-all-options']) { |
388 printOptions(optionsParser, options, true, stdout); | 387 printOptions(optionsParser, options, true, stdout); |
389 } else { | 388 } else { |
390 var config = new Map(); | 389 var config = new Map(); |
391 for (var option in options.options) { | 390 for (var option in options.options) { |
392 config[option] = options[option]; | 391 config[option] = options[option]; |
393 } | 392 } |
(...skipping 19 matching lines...) Expand all Loading... |
413 if (dirs.length == 0) { | 412 if (dirs.length == 0) { |
414 dirs.add('.'); // Use current working directory as default. | 413 dirs.add('.'); // Use current working directory as default. |
415 } | 414 } |
416 var f = buildFileList(dirs, | 415 var f = buildFileList(dirs, |
417 new RegExp(config['test-file-pattern']), config['recurse']); | 416 new RegExp(config['test-file-pattern']), config['recurse']); |
418 if (config['sort']) f.sort(); | 417 if (config['sort']) f.sort(); |
419 processTests(config, f); | 418 processTests(config, f); |
420 } | 419 } |
421 } | 420 } |
422 } | 421 } |
OLD | NEW |