@@ -33,6 +33,20 @@ void main() {
3333}
3434""" ;
3535
36+ final _asyncFailure = """
37+ import 'dart:async';
38+
39+ import 'package:test/test.dart';
40+
41+ void main() {
42+ test("failure", () async{
43+ await new Future((){});
44+ await new Future((){});
45+ throw "oh no";
46+ });
47+ }
48+ """ ;
49+
3650final _defaultConcurrency = math.max (1 , Platform .numberOfProcessors ~ / 2 );
3751
3852final _browsers =
@@ -44,52 +58,58 @@ final _browsers =
4458final _usage = """
4559Usage: pub run test [files or directories...]
4660
47- -h, --help Shows this usage information.
48- --version Shows the package's version.
61+ -h, --help Shows this usage information.
62+ --version Shows the package's version.
4963
5064======== Selecting Tests
51- -n, --name A substring of the name of the test to run.
52- Regular expression syntax is supported.
53- If passed multiple times, tests must match all substrings.
65+ -n, --name A substring of the name of the test to run.
66+ Regular expression syntax is supported.
67+ If passed multiple times, tests must match all substrings.
5468
55- -N, --plain-name A plain-text substring of the name of the test to run.
56- If passed multiple times, tests must match all substrings.
69+ -N, --plain-name A plain-text substring of the name of the test to run.
70+ If passed multiple times, tests must match all substrings.
5771
58- -t, --tags Run only tests with all of the specified tags.
59- Supports boolean selector syntax.
72+ -t, --tags Run only tests with all of the specified tags.
73+ Supports boolean selector syntax.
6074
61- -x, --exclude-tags Don't run tests with any of the specified tags.
62- Supports boolean selector syntax.
75+ -x, --exclude-tags Don't run tests with any of the specified tags.
76+ Supports boolean selector syntax.
6377
64- --[no-]run-skipped Run skipped tests instead of skipping them.
78+ --[no-]run-skipped Run skipped tests instead of skipping them.
6579
6680======== Running Tests
67- -p, --platform The platform(s) on which to run the tests.
68- $_browsers
81+ -p, --platform The platform(s) on which to run the tests.
82+ $_browsers
6983
70- -P, --preset The configuration preset(s) to use.
71- -j, --concurrency=<threads> The number of concurrent test suites run.
72- (defaults to "$_defaultConcurrency ")
84+ -P, --preset The configuration preset(s) to use.
85+ -j, --concurrency=<threads> The number of concurrent test suites run.
86+ (defaults to "$_defaultConcurrency ")
7387
74- --pub-serve=<port> The port of a pub serve instance serving "test/".
75- --timeout The default test timeout. For example: 15s, 2x, none
76- (defaults to "30s")
88+ --pub-serve=<port> The port of a pub serve instance serving "test/".
89+ --timeout The default test timeout. For example: 15s, 2x, none
90+ (defaults to "30s")
7791
78- --pause-after-load Pauses for debugging before any tests execute.
79- Implies --concurrency=1 and --timeout=none.
80- Currently only supported for browser tests.
92+ --pause-after-load Pauses for debugging before any tests execute.
93+ Implies --concurrency=1 and --timeout=none.
94+ Currently only supported for browser tests.
95+
96+ --[no-]chain-stack-traces Chained stack traces to provide greater exception details
97+ especially for asynchronous code. It may be useful to disable
98+ to provide improved test performance but at the cost of
99+ debuggability.
100+ (defaults to on)
81101
82102======== Output
83- -r, --reporter The runner used to print test results.
103+ -r, --reporter The runner used to print test results.
84104
85- [compact] A single line, updated continuously.
86- [expanded] A separate line for each update.
87- [json] A machine-readable format (see https://goo.gl/gBsV1a).
105+ [compact] A single line, updated continuously.
106+ [expanded] A separate line for each update.
107+ [json] A machine-readable format (see https://goo.gl/gBsV1a).
88108
89- --verbose-trace Whether to emit stack traces with core library frames.
90- --js-trace Whether to emit raw JavaScript stack traces for browser tests.
91- --[no-]color Whether to use terminal colors.
92- (auto-detected by default)
109+ --verbose-trace Whether to emit stack traces with core library frames.
110+ --js-trace Whether to emit raw JavaScript stack traces for browser tests.
111+ --[no-]color Whether to use terminal colors.
112+ (auto-detected by default)
93113""" ;
94114
95115void main () {
@@ -323,6 +343,27 @@ $_usage""");
323343 });
324344
325345 group ("runs failing tests" , () {
346+ test ("defaults to chaining stack traces" , () {
347+ d.file ("test.dart" , _asyncFailure).create ();
348+
349+ var test = runTest (["test.dart" ]);
350+ test.stdout.expect (consumeThrough (contains ("asynchronous gap" )));
351+ test.shouldExit (1 );
352+ });
353+
354+ test ("respects the chain-stack-traces flag" , () {
355+ d.file ("test.dart" , _asyncFailure).create ();
356+
357+ var test = runTest (["test.dart" , "--no-chain-stack-traces" ]);
358+ test.stdout.expect (containsInOrder ([
359+ "00:00 +0: failure" ,
360+ "00:00 +0 -1: failure [E]" ,
361+ "oh no" ,
362+ "test.dart 9:5 main.<fn>" ,
363+ ]));
364+ test.shouldExit (1 );
365+ });
366+
326367 test ("defined in a single file" , () {
327368 d.file ("test.dart" , _failure).create ();
328369
0 commit comments