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/test_platform.dart'; | 18 import 'backend/test_platform.dart'; |
19 import 'runner/reporter/compact.dart'; | 19 import 'runner/reporter/compact.dart'; |
| 20 import 'runner/reporter/expanded.dart'; |
20 import 'runner/application_exception.dart'; | 21 import 'runner/application_exception.dart'; |
21 import 'runner/load_exception.dart'; | 22 import 'runner/load_exception.dart'; |
22 import 'runner/load_exception_suite.dart'; | 23 import 'runner/load_exception_suite.dart'; |
23 import 'runner/loader.dart'; | 24 import 'runner/loader.dart'; |
24 import 'util/exit_codes.dart' as exit_codes; | 25 import 'util/exit_codes.dart' as exit_codes; |
25 import 'util/io.dart'; | 26 import 'util/io.dart'; |
26 import 'utils.dart'; | 27 import 'utils.dart'; |
27 | 28 |
28 /// The argument parser used to parse the executable arguments. | 29 /// The argument parser used to parse the executable arguments. |
29 final _parser = new ArgParser(allowTrailingOptions: true); | 30 final _parser = new ArgParser(allowTrailingOptions: true); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 allowMultiple: true); | 96 allowMultiple: true); |
96 _parser.addOption("concurrency", | 97 _parser.addOption("concurrency", |
97 abbr: 'j', | 98 abbr: 'j', |
98 help: 'The number of concurrent test suites run.\n' | 99 help: 'The number of concurrent test suites run.\n' |
99 '(defaults to $_defaultConcurrency)', | 100 '(defaults to $_defaultConcurrency)', |
100 valueHelp: 'threads'); | 101 valueHelp: 'threads'); |
101 _parser.addOption("pub-serve", | 102 _parser.addOption("pub-serve", |
102 help: 'The port of a pub serve instance serving "test/".', | 103 help: 'The port of a pub serve instance serving "test/".', |
103 hide: !supportsPubServe, | 104 hide: !supportsPubServe, |
104 valueHelp: 'port'); | 105 valueHelp: 'port'); |
| 106 _parser.addOption("reporter", |
| 107 abbr: 'r', |
| 108 help: 'The runner used to print test results.', |
| 109 allowed: ['compact', 'expanded'], |
| 110 defaultsTo: Platform.isWindows ? 'expanded' : 'compact', |
| 111 allowedHelp: { |
| 112 'compact': 'A single line, updated continuously.', |
| 113 'expanded': 'A separate line for each update.' |
| 114 }); |
105 _parser.addFlag("color", defaultsTo: null, | 115 _parser.addFlag("color", defaultsTo: null, |
106 help: 'Whether to use terminal colors.\n(auto-detected by default)'); | 116 help: 'Whether to use terminal colors.\n(auto-detected by default)'); |
107 | 117 |
108 var options; | 118 var options; |
109 try { | 119 try { |
110 options = _parser.parse(args); | 120 options = _parser.parse(args); |
111 } on FormatException catch (error) { | 121 } on FormatException catch (error) { |
112 _printUsage(error.message); | 122 _printUsage(error.message); |
113 exitCode = exit_codes.usage; | 123 exitCode = exit_codes.usage; |
114 return; | 124 return; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 if (pattern is RegExp) { | 237 if (pattern is RegExp) { |
228 stderr.writeln('regular expression "${pattern.pattern}".'); | 238 stderr.writeln('regular expression "${pattern.pattern}".'); |
229 } else { | 239 } else { |
230 stderr.writeln('"$pattern".'); | 240 stderr.writeln('"$pattern".'); |
231 } | 241 } |
232 exitCode = exit_codes.data; | 242 exitCode = exit_codes.data; |
233 return null; | 243 return null; |
234 } | 244 } |
235 } | 245 } |
236 | 246 |
237 var reporter = new CompactReporter(flatten(suites), | 247 var reporter = options["reporter"] == "compact" |
238 concurrency: concurrency, color: color); | 248 ? new CompactReporter(flatten(suites), |
| 249 concurrency: concurrency, color: color) |
| 250 : new ExpandedReporter(flatten(suites), |
| 251 concurrency: concurrency, color: color); |
239 | 252 |
240 // Override the signal handler to close [reporter]. [loader] will still be | 253 // Override the signal handler to close [reporter]. [loader] will still be |
241 // closed in the [whenComplete] below. | 254 // closed in the [whenComplete] below. |
242 signalSubscription.onData((_) { | 255 signalSubscription.onData((_) { |
243 signalSubscription.cancel(); | 256 signalSubscription.cancel(); |
244 closed = true; | 257 closed = true; |
245 | 258 |
246 // Wait a bit to print this message, since printing it eagerly looks weird | 259 // Wait a bit to print this message, since printing it eagerly looks weird |
247 // if the tests then finish immediately. | 260 // if the tests then finish immediately. |
248 var timer = new Timer(new Duration(seconds: 1), () { | 261 var timer = new Timer(new Duration(seconds: 1), () { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if (description is! Map) return false; | 369 if (description is! Map) return false; |
357 var path = description["path"]; | 370 var path = description["path"]; |
358 if (path is! String) return false; | 371 if (path is! String) return false; |
359 | 372 |
360 print("$version (from $path)"); | 373 print("$version (from $path)"); |
361 return true; | 374 return true; |
362 | 375 |
363 default: return false; | 376 default: return false; |
364 } | 377 } |
365 } | 378 } |
OLD | NEW |