| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(nweiz): This is under lib so that it can be used by the unittest dummy | 5 // TODO(nweiz): This is under lib so that it can be used by the unittest dummy |
| 6 // package. Once that package is no longer being updated, move this back into | 6 // package. Once that package is no longer being updated, move this back into |
| 7 // bin. | 7 // bin. |
| 8 library test.executable; | 8 library test.executable; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 import 'dart:io'; | 11 import 'dart:io'; |
| 12 import 'dart:math' as math; | 12 import 'dart:math' as math; |
| 13 | 13 |
| 14 import 'package:args/args.dart'; | 14 import 'package:args/args.dart'; |
| 15 import 'package:stack_trace/stack_trace.dart'; | 15 import 'package:stack_trace/stack_trace.dart'; |
| 16 import 'package:yaml/yaml.dart'; | 16 import 'package:yaml/yaml.dart'; |
| 17 | 17 |
| 18 import 'backend/metadata.dart'; |
| 18 import 'backend/test_platform.dart'; | 19 import 'backend/test_platform.dart'; |
| 19 import 'runner/reporter/compact.dart'; | 20 import 'runner/reporter/compact.dart'; |
| 20 import 'runner/reporter/expanded.dart'; | 21 import 'runner/reporter/expanded.dart'; |
| 21 import 'runner/application_exception.dart'; | 22 import 'runner/application_exception.dart'; |
| 22 import 'runner/load_exception.dart'; | 23 import 'runner/load_exception.dart'; |
| 23 import 'runner/load_exception_suite.dart'; | 24 import 'runner/load_exception_suite.dart'; |
| 24 import 'runner/loader.dart'; | 25 import 'runner/loader.dart'; |
| 25 import 'util/exit_codes.dart' as exit_codes; | 26 import 'util/exit_codes.dart' as exit_codes; |
| 26 import 'util/io.dart'; | 27 import 'util/io.dart'; |
| 27 import 'utils.dart'; | 28 import 'utils.dart'; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 valueHelp: 'port'); | 110 valueHelp: 'port'); |
| 110 _parser.addOption("reporter", | 111 _parser.addOption("reporter", |
| 111 abbr: 'r', | 112 abbr: 'r', |
| 112 help: 'The runner used to print test results.', | 113 help: 'The runner used to print test results.', |
| 113 allowed: ['compact', 'expanded'], | 114 allowed: ['compact', 'expanded'], |
| 114 defaultsTo: Platform.isWindows ? 'expanded' : 'compact', | 115 defaultsTo: Platform.isWindows ? 'expanded' : 'compact', |
| 115 allowedHelp: { | 116 allowedHelp: { |
| 116 'compact': 'A single line, updated continuously.', | 117 'compact': 'A single line, updated continuously.', |
| 117 'expanded': 'A separate line for each update.' | 118 'expanded': 'A separate line for each update.' |
| 118 }); | 119 }); |
| 120 _parser.addFlag("verbose-trace", negatable: false, |
| 121 help: 'Whether to emit stack traces with core library frames.'); |
| 119 _parser.addFlag("color", defaultsTo: null, | 122 _parser.addFlag("color", defaultsTo: null, |
| 120 help: 'Whether to use terminal colors.\n(auto-detected by default)'); | 123 help: 'Whether to use terminal colors.\n(auto-detected by default)'); |
| 121 | 124 |
| 122 var options; | 125 var options; |
| 123 try { | 126 try { |
| 124 options = _parser.parse(args); | 127 options = _parser.parse(args); |
| 125 } on FormatException catch (error) { | 128 } on FormatException catch (error) { |
| 126 _printUsage(error.message); | 129 _printUsage(error.message); |
| 127 exitCode = exit_codes.usage; | 130 exitCode = exit_codes.usage; |
| 128 return; | 131 return; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 154 | 157 |
| 155 transformers: | 158 transformers: |
| 156 - test/pub_serve: | 159 - test/pub_serve: |
| 157 \$include: test/**_test.dart | 160 \$include: test/**_test.dart |
| 158 '''); | 161 '''); |
| 159 exitCode = exit_codes.data; | 162 exitCode = exit_codes.data; |
| 160 return; | 163 return; |
| 161 } | 164 } |
| 162 } | 165 } |
| 163 | 166 |
| 167 var metadata = new Metadata(verboseTrace: options["verbose-trace"]); |
| 164 var platforms = options["platform"].map(TestPlatform.find); | 168 var platforms = options["platform"].map(TestPlatform.find); |
| 165 var loader = new Loader(platforms, | 169 var loader = new Loader(platforms, |
| 166 pubServeUrl: pubServeUrl, | 170 pubServeUrl: pubServeUrl, |
| 167 packageRoot: options["package-root"], | 171 packageRoot: options["package-root"], |
| 168 color: color); | 172 color: color, |
| 173 metadata: metadata); |
| 169 | 174 |
| 170 var concurrency = _defaultConcurrency; | 175 var concurrency = _defaultConcurrency; |
| 171 if (options["concurrency"] != null) { | 176 if (options["concurrency"] != null) { |
| 172 try { | 177 try { |
| 173 concurrency = int.parse(options["concurrency"]); | 178 concurrency = int.parse(options["concurrency"]); |
| 174 } catch (error) { | 179 } catch (error) { |
| 175 _printUsage('Couldn\'t parse --concurrency "${options["concurrency"]}":' | 180 _printUsage('Couldn\'t parse --concurrency "${options["concurrency"]}":' |
| 176 ' ${error.message}'); | 181 ' ${error.message}'); |
| 177 exitCode = exit_codes.usage; | 182 exitCode = exit_codes.usage; |
| 178 return; | 183 return; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 stderr.writeln('regular expression "${pattern.pattern}".'); | 247 stderr.writeln('regular expression "${pattern.pattern}".'); |
| 243 } else { | 248 } else { |
| 244 stderr.writeln('"$pattern".'); | 249 stderr.writeln('"$pattern".'); |
| 245 } | 250 } |
| 246 exitCode = exit_codes.data; | 251 exitCode = exit_codes.data; |
| 247 return null; | 252 return null; |
| 248 } | 253 } |
| 249 } | 254 } |
| 250 | 255 |
| 251 var reporter = options["reporter"] == "compact" | 256 var reporter = options["reporter"] == "compact" |
| 252 ? new CompactReporter(flatten(suites), | 257 ? new CompactReporter( |
| 253 concurrency: concurrency, color: color) | 258 flatten(suites), |
| 254 : new ExpandedReporter(flatten(suites), | 259 concurrency: concurrency, |
| 255 concurrency: concurrency, color: color); | 260 color: color, |
| 261 verboseTrace: options["verbose-trace"]) |
| 262 : new ExpandedReporter( |
| 263 flatten(suites), |
| 264 concurrency: concurrency, |
| 265 color: color, |
| 266 verboseTrace: options["verbose-trace"]); |
| 256 | 267 |
| 257 // Override the signal handler to close [reporter]. [loader] will still be | 268 // Override the signal handler to close [reporter]. [loader] will still be |
| 258 // closed in the [whenComplete] below. | 269 // closed in the [whenComplete] below. |
| 259 signalSubscription.onData((_) { | 270 signalSubscription.onData((_) { |
| 260 signalSubscription.cancel(); | 271 signalSubscription.cancel(); |
| 261 closed = true; | 272 closed = true; |
| 262 | 273 |
| 263 // Wait a bit to print this message, since printing it eagerly looks weird | 274 // Wait a bit to print this message, since printing it eagerly looks weird |
| 264 // if the tests then finish immediately. | 275 // if the tests then finish immediately. |
| 265 var timer = new Timer(new Duration(seconds: 1), () { | 276 var timer = new Timer(new Duration(seconds: 1), () { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 if (description is! Map) return false; | 384 if (description is! Map) return false; |
| 374 var path = description["path"]; | 385 var path = description["path"]; |
| 375 if (path is! String) return false; | 386 if (path is! String) return false; |
| 376 | 387 |
| 377 print("$version (from $path)"); | 388 print("$version (from $path)"); |
| 378 return true; | 389 return true; |
| 379 | 390 |
| 380 default: return false; | 391 default: return false; |
| 381 } | 392 } |
| 382 } | 393 } |
| OLD | NEW |