Skip to content

Commit 07c15f5

Browse files
authored
fix(lexarg): Improve help output (#126)
This is based on my experience adopting libtest2-mimic in a project
2 parents 9089916 + fa5ba7a commit 07c15f5

File tree

1 file changed

+34
-58
lines changed
  • crates/libtest-lexarg/src

1 file changed

+34
-58
lines changed

crates/libtest-lexarg/src/lib.rs

Lines changed: 34 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -90,67 +90,43 @@ impl Default for OutputFormat {
9090
pub const UNSTABLE_OPTIONS: &str = "unstable-options";
9191

9292
pub const OPTIONS_HELP: &str = r#"
93+
Arguments:
94+
[FILTER]... Skip tests whose name does not match one of the filters
95+
9396
Options:
94-
--skip FILTER Skip tests whose names contain FILTER (this flag can
95-
be used multiple times)
96-
--exact Exactly match filters rather than by substring
97-
--test Run tests and not benchmarks
98-
--bench Run benchmarks instead of tests
99-
--ignored Run only ignored tests
100-
--include-ignored
101-
Run ignored and not ignored tests
102-
--fail-fast Don't start new tests after the first failure
103-
--no-capture don't capture stdout/stderr of each task, allow
104-
printing directly
105-
--show-output Show captured stdout of successful tests
106-
--test-threads n_threads
107-
Number of threads used for running tests in parallel
108-
--color auto|always|never
109-
Configure coloring of output:
110-
auto = colorize if stdout is a tty and tests are run
111-
on serially (default);
112-
always = always colorize output;
113-
never = never colorize output;
114-
--format pretty|terse|json
115-
Configure formatting of output:
116-
pretty = Print verbose output;
117-
terse = Display one character per test;
118-
json = Output a json document;
119-
--list List all tests and benchmarks
120-
-q, --quiet Display one character per test instead of one line.
121-
Alias to --format=terse
122-
-Z unstable-options Enable nightly-only flags:
123-
unstable-options = Allow use of experimental features
97+
--fail-fast Don't start new tests after the first failure
98+
--skip FILTER Skip tests whose names contain FILTER
99+
(this flag can be used multiple times)
100+
--exact Exactly match filters rather than by substring
101+
--ignored Run only ignored tests
102+
--include-ignored
103+
Run ignored and not ignored tests
104+
--test Run tests and not benchmarks
105+
--bench Run benchmarks instead of tests
106+
--no-capture don't capture stdout/stderr of each task,
107+
allow printing directly
108+
--show-output Show captured stdout of successful tests
109+
--list List all tests and benchmarks
110+
--test-threads NUM
111+
Number of threads used for running tests in parallel
112+
(default is >1)
113+
--format <pretty|terse|json>
114+
Configure formatting of output:
115+
- pretty: Print verbose output
116+
- terse: Display one character per test
117+
- json: Output a json document
118+
-q, --quiet Display one character per test instead of one line
119+
(alias to --format=terse)
120+
--color <auto|always|never>
121+
Configure coloring of output:
122+
- auto: detect terminal support (default)
123+
- always: always colorize output
124+
- never: never colorize output
125+
-Z FLAG Enable nightly-only flags:
126+
- unstable-options: Allow use of experimental features
124127
"#;
125128

126-
pub const AFTER_HELP: &str = r#"
127-
The FILTER string is tested against the name of all tests, and only those
128-
tests whose names contain the filter are run. Multiple filter strings may
129-
be passed, which will run all tests matching any of the filters.
130-
131-
By default, all tests are run in parallel. This can be altered with the
132-
--test-threads flag when running
133-
tests (set it to 1).
134-
135-
All tests have their standard output and standard error captured by default.
136-
This can be overridden with the --no-capture flag to a value other than "0".
137-
Logging is not captured by default.
138-
139-
Test Attributes:
140-
141-
`#[test]` - Indicates a function is a test to be run. This function
142-
takes no arguments.
143-
`#[bench]` - Indicates a function is a benchmark to be run. This
144-
function takes one argument (test::Bencher).
145-
`#[should_panic]` - This function (also labeled with `#[test]`) will only pass if
146-
the code causes a panic (an assertion failure or panic!)
147-
A message may be provided, which the failure string must
148-
contain: #[should_panic(expected = "foo")].
149-
`#[ignore]` - When applied to a function which is already attributed as a
150-
test, then the test runner will ignore these tests during
151-
normal test runs. Running with --ignored or --include-ignored will run
152-
these tests.
153-
"#;
129+
pub const AFTER_HELP: &str = r#""#;
154130

155131
/// Intermediate CLI parser state for [`TestOpts`]
156132
///

0 commit comments

Comments
 (0)