Skip to content

Commit 79ac9eb

Browse files
authored
Clean up --help (#1331)
Clean up `--help` to better align with other commands captured in Dart CLI. Closes #1330
1 parent 34ad806 commit 79ac9eb

File tree

7 files changed

+55
-43
lines changed

7 files changed

+55
-43
lines changed

pkgs/test/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.16.0-nullsafety.3
2+
3+
* Clean up `--help` output.
4+
15
## 1.16.0-nullsafety.2
26

37
* Allow version `0.40.x` of `analyzer`.

pkgs/test/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: test
2-
version: 1.16.0-nullsafety.2
2+
version: 1.16.0-nullsafety.3
33
description: A full featured library for writing and running Dart tests.
44
homepage: https://github.com/dart-lang/test/blob/master/pkgs/test
55

@@ -34,7 +34,7 @@ dependencies:
3434
yaml: ^2.0.0
3535
# Use an exact version until the test_api and test_core package are stable.
3636
test_api: 0.2.19-nullsafety
37-
test_core: 0.3.12-nullsafety.2
37+
test_core: 0.3.12-nullsafety.3
3838

3939
dev_dependencies:
4040
fake_async: ^1.0.0

pkgs/test/test/runner/runner_test.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'dart:math' as math;
1313

1414
import 'package:package_config/package_config.dart';
1515
import 'package:path/path.dart' as p;
16-
1716
import 'package:test/test.dart';
1817
import 'package:test_core/src/util/exit_codes.dart' as exit_codes;
1918
import 'package:test_descriptor/test_descriptor.dart' as d;
@@ -59,10 +58,10 @@ final _defaultConcurrency = math.max(1, Platform.numberOfProcessors ~/ 2);
5958
final _usage = '''
6059
Usage: pub run test [files or directories...]
6160
62-
-h, --help Shows this usage information.
63-
--version Shows the package's version.
61+
-h, --help Show this usage information.
62+
--version Show the package:test version.
6463
65-
======== Selecting Tests
64+
Selecting Tests:
6665
-n, --name A substring of the name of the test to run.
6766
Regular expression syntax is supported.
6867
If passed multiple times, tests must match all substrings.
@@ -74,7 +73,7 @@ Usage: pub run test [files or directories...]
7473
Supports boolean selector syntax.
7574
--[no-]run-skipped Run skipped tests instead of skipping them.
7675
77-
======== Running Tests
76+
Running Tests:
7877
-p, --platform The platform(s) on which to run the tests.
7978
$_browsers
8079
-P, --preset The configuration preset(s) to use.
@@ -85,36 +84,37 @@ Usage: pub run test [files or directories...]
8584
--pub-serve=<port> The port of a pub serve instance serving "test/".
8685
--timeout The default test timeout. For example: 15s, 2x, none
8786
(defaults to "30s")
88-
--pause-after-load Pauses for debugging before any tests execute.
87+
--pause-after-load Pause for debugging before any tests execute.
8988
Implies --concurrency=1, --debug, and --timeout=none.
9089
Currently only supported for browser tests.
91-
--debug Runs the VM and Chrome tests in debug mode.
92-
--coverage=<directory> Gathers coverage and outputs it to the specified directory.
90+
--debug Run the VM and Chrome tests in debug mode.
91+
--coverage=<directory> Gather coverage and output it to the specified directory.
9392
Implies --debug.
94-
--[no-]chain-stack-traces Chained stack traces to provide greater exception details
93+
--[no-]chain-stack-traces Use chained stack traces to provide greater exception details
9594
especially for asynchronous code. It may be useful to disable
9695
to provide improved test performance but at the cost of
9796
debuggability.
9897
(defaults to on)
99-
--no-retry Don't re-run tests that have retry set.
100-
--test-randomize-ordering-seed The seed to randomize the execution order of test cases.
98+
--no-retry Don't rerun tests that have retry set.
99+
--test-randomize-ordering-seed Use the specified seed to randomize the execution order of test cases.
101100
Must be a 32bit unsigned integer or "random".
102101
If "random", pick a random seed to use.
103102
If not passed, do not randomize test case execution order.
104103
105-
======== Output
106-
-r, --reporter The runner used to print test results.
104+
Output:
105+
-r, --reporter Set how to print test results.
107106
108107
[compact] A single line, updated continuously.
109108
[expanded] (default) A separate line for each update.
110-
[json] A machine-readable format (see https://bit.ly/2Z7J0OH).
109+
[json] A machine-readable format (see https://dart.dev/go/test-docs/json_reporter.md).
111110
112-
--file-reporter The reporter used to write test results to a file.
113-
Should be in the form <reporter>:<filepath>, e.g. "json:reports/tests.json"
114-
--verbose-trace Whether to emit stack traces with core library frames.
115-
--js-trace Whether to emit raw JavaScript stack traces for browser tests.
116-
--[no-]color Whether to use terminal colors.
111+
--file-reporter Set the reporter used to write test results to a file.
112+
Should be in the form <reporter>:<filepath>, Example: "json:reports/tests.json"
113+
--verbose-trace Emit stack traces with core library frames.
114+
--js-trace Emit raw JavaScript stack traces for browser tests.
115+
--[no-]color Use terminal colors.
117116
(auto-detected by default)
117+
118118
''';
119119

120120
final _browsers = '[vm (default), chrome, phantomjs, firefox' +

pkgs/test_core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.12-nullsafety.3
2+
3+
* Clean up `--help` output.
4+
15
## 0.3.12-nullsafety.2
26

37
* Allow version `0.40.x` of `analyzer`.

pkgs/test_core/lib/src/runner/configuration/args.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ final ArgParser _parser = (() {
2525
if (!Platform.isWindows) allRuntimes.remove(Runtime.internetExplorer);
2626

2727
parser.addFlag('help',
28-
abbr: 'h', negatable: false, help: 'Shows this usage information.');
28+
abbr: 'h', negatable: false, help: 'Show this usage information.');
2929
parser.addFlag('version',
30-
negatable: false, help: "Shows the package's version.");
30+
negatable: false, help: 'Show the package:test version.');
3131

3232
// Note that defaultsTo declarations here are only for documentation purposes.
3333
// We pass null instead of the default so that it merges properly with the
3434
// config file.
3535

36-
parser.addSeparator('======== Selecting Tests');
36+
parser.addSeparator('Selecting Tests:');
3737
parser.addMultiOption('name',
3838
abbr: 'n',
3939
help: 'A substring of the name of the test to run.\n'
@@ -58,7 +58,7 @@ final ArgParser _parser = (() {
5858
parser.addFlag('run-skipped',
5959
help: 'Run skipped tests instead of skipping them.');
6060

61-
parser.addSeparator('======== Running Tests');
61+
parser.addSeparator('Running Tests:');
6262

6363
// The UI term "platform" corresponds with the implementation term "runtime".
6464
// The [Runtime] class used to be called [TestPlatform], but it was changed to
@@ -87,28 +87,29 @@ final ArgParser _parser = (() {
8787
help: 'The default test timeout. For example: 15s, 2x, none',
8888
defaultsTo: '30s');
8989
parser.addFlag('pause-after-load',
90-
help: 'Pauses for debugging before any tests execute.\n'
90+
help: 'Pause for debugging before any tests execute.\n'
9191
'Implies --concurrency=1, --debug, and --timeout=none.\n'
9292
'Currently only supported for browser tests.',
9393
negatable: false);
9494
parser.addFlag('debug',
95-
help: 'Runs the VM and Chrome tests in debug mode.', negatable: false);
95+
help: 'Run the VM and Chrome tests in debug mode.', negatable: false);
9696
parser.addOption('coverage',
97-
help: 'Gathers coverage and outputs it to the specified directory.\n'
97+
help: 'Gather coverage and output it to the specified directory.\n'
9898
'Implies --debug.',
9999
valueHelp: 'directory');
100100
parser.addFlag('chain-stack-traces',
101-
help: 'Chained stack traces to provide greater exception details\n'
101+
help: 'Use chained stack traces to provide greater exception details\n'
102102
'especially for asynchronous code. It may be useful to disable\n'
103103
'to provide improved test performance but at the cost of\n'
104104
'debuggability.',
105105
defaultsTo: true);
106106
parser.addFlag('no-retry',
107-
help: "Don't re-run tests that have retry set.",
107+
help: "Don't rerun tests that have retry set.",
108108
defaultsTo: false,
109109
negatable: false);
110110
parser.addOption('test-randomize-ordering-seed',
111-
help: 'The seed to randomize the execution order of test cases.\n'
111+
help: 'Use the specified seed to randomize the execution order of test'
112+
' cases.\n'
112113
'Must be a 32bit unsigned integer or "random".\n'
113114
'If "random", pick a random seed to use.\n'
114115
'If not passed, do not randomize test case execution order.');
@@ -118,25 +119,24 @@ final ArgParser _parser = (() {
118119
reporterDescriptions[reporter] = allReporters[reporter]!.description;
119120
}
120121

121-
parser.addSeparator('======== Output');
122+
parser.addSeparator('Output:');
122123
parser.addOption('reporter',
123124
abbr: 'r',
124-
help: 'The runner used to print test results.',
125+
help: 'Set how to print test results.',
125126
defaultsTo: defaultReporter,
126127
allowed: reporterDescriptions.keys.toList(),
127128
allowedHelp: reporterDescriptions);
128129
parser.addOption('file-reporter',
129-
help: 'The reporter used to write test results to a file.\n'
130+
help: 'Set the reporter used to write test results to a file.\n'
130131
'Should be in the form <reporter>:<filepath>, '
131-
'e.g. "json:reports/tests.json"');
132+
'Example: "json:reports/tests.json"');
132133
parser.addFlag('verbose-trace',
133-
negatable: false,
134-
help: 'Whether to emit stack traces with core library frames.');
134+
negatable: false, help: 'Emit stack traces with core library frames.');
135135
parser.addFlag('js-trace',
136136
negatable: false,
137-
help: 'Whether to emit raw JavaScript stack traces for browser tests.');
137+
help: 'Emit raw JavaScript stack traces for browser tests.');
138138
parser.addFlag('color',
139-
help: 'Whether to use terminal colors.\n(auto-detected by default)');
139+
help: 'Use terminal colors.\n(auto-detected by default)');
140140

141141
/// The following options are used only by the internal Google test runner.
142142
/// They're hidden and not supported as stable API surface outside Google.

pkgs/test_core/lib/src/runner/configuration/reporters.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ final _allReporters = <String, ReporterDetails>{
4444
Directory(config.paths.single).existsSync(),
4545
printPlatform: config.suiteDefaults.runtimes.length > 1)),
4646
'json': ReporterDetails(
47-
'A machine-readable format (see https://bit.ly/2Z7J0OH).',
47+
'A machine-readable format (see '
48+
'https://dart.dev/go/test-docs/json_reporter.md).',
4849
(_, engine, sink) => JsonReporter.watch(engine, sink)),
4950
};
5051

51-
final defaultReporter =
52-
inTestTests ? 'expanded' : canUseSpecialChars ? 'compact' : 'expanded';
52+
final defaultReporter = inTestTests
53+
? 'expanded'
54+
: canUseSpecialChars
55+
? 'compact'
56+
: 'expanded';
5357

5458
/// **Do not call this function without express permission from the test package
5559
/// authors**.

pkgs/test_core/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: test_core
2-
version: 0.3.12-nullsafety.2
2+
version: 0.3.12-nullsafety.3
33
description: A basic library for writing tests and running them on the VM.
44
homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_core
55

0 commit comments

Comments
 (0)