Skip to content

Commit 8e89670

Browse files
committed
Auto merge of #8552 - icorbrey:test-name-filtering-docs, r=ehuss
Clarify test name filter usage I set aside the description of the usage example in the top description section and added a more concise example in the example section at the bottom of the man page. I also changed the wording of the usage example up top a bit to be more search-friendly since "filter" is a common keyword to search for. Resolves #8282
2 parents 272cfc0 + c666342 commit 8e89670

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

src/doc/man/cargo-test.adoc

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ dashes (`--`) are passed to the test binaries and thus to _libtest_ (rustc's
2121
built in unit-test and micro-benchmarking framework). If you're passing
2222
arguments to both Cargo and the binary, the ones after `--` go to the binary,
2323
the ones before go to Cargo. For details about libtest's arguments see the
24-
output of `cargo test \-- --help`. As an example, this will run all tests with
25-
`foo` in their name on 3 threads in parallel:
24+
output of `cargo test \-- --help`.
25+
26+
As an example, this will filter for tests with `foo` in their name and run them
27+
on 3 threads in parallel:
2628

2729
cargo test foo -- --test-threads 3
2830

@@ -152,6 +154,10 @@ include::section-exit-status.adoc[]
152154

153155
cargo test
154156

157+
. Run only tests whose names match against a filter string:
158+
159+
cargo test name_filter
160+
155161
. Run only a specific test within a specific integration test:
156162

157163
cargo test --test int_test_name -- modname::test_name

src/doc/man/generated/cargo-test.html

+13-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ <h2 id="cargo_test_description">DESCRIPTION</h2>
2222
built in unit-test and micro-benchmarking framework). If you&#8217;re passing
2323
arguments to both Cargo and the binary, the ones after <code>--</code> go to the binary,
2424
the ones before go to Cargo. For details about libtest&#8217;s arguments see the
25-
output of <code>cargo test -- --help</code>. As an example, this will run all tests with
26-
<code>foo</code> in their name on 3 threads in parallel:</p>
25+
output of <code>cargo test -- --help</code>.</p>
26+
</div>
27+
<div class="paragraph">
28+
<p>As an example, this will filter for tests with <code>foo</code> in their name and run them
29+
on 3 threads in parallel:</p>
2730
</div>
2831
<div class="literalblock">
2932
<div class="content">
@@ -581,6 +584,14 @@ <h2 id="cargo_test_examples">EXAMPLES</h2>
581584
</div>
582585
</li>
583586
<li>
587+
<p>Run only tests whose names match against a filter string:</p>
588+
<div class="literalblock">
589+
<div class="content">
590+
<pre>cargo test name_filter</pre>
591+
</div>
592+
</div>
593+
</li>
594+
<li>
584595
<p>Run only a specific test within a specific integration test:</p>
585596
<div class="literalblock">
586597
<div class="content">

src/etc/man/cargo-test.1

+23-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
.\" Title: cargo-test
33
.\" Author: [see the "AUTHOR(S)" section]
44
.\" Generator: Asciidoctor 2.0.10
5-
.\" Date: 2020-06-25
5+
.\" Date: 2020-07-28
66
.\" Manual: \ \&
77
.\" Source: \ \&
88
.\" Language: English
99
.\"
10-
.TH "CARGO\-TEST" "1" "2020-06-25" "\ \&" "\ \&"
10+
.TH "CARGO\-TEST" "1" "2020-07-28" "\ \&" "\ \&"
1111
.ie \n(.g .ds Aq \(aq
1212
.el .ds Aq '
1313
.ss \n[.ss] 0
@@ -41,8 +41,10 @@ dashes (\fB\-\-\fP) are passed to the test binaries and thus to \fIlibtest\fP (r
4141
built in unit\-test and micro\-benchmarking framework). If you\(cqre passing
4242
arguments to both Cargo and the binary, the ones after \fB\-\-\fP go to the binary,
4343
the ones before go to Cargo. For details about libtest\(cqs arguments see the
44-
output of \fBcargo test \-\- \-\-help\fP. As an example, this will run all tests with
45-
\fBfoo\fP in their name on 3 threads in parallel:
44+
output of \fBcargo test \-\- \-\-help\fP.
45+
.sp
46+
As an example, this will filter for tests with \fBfoo\fP in their name and run them
47+
on 3 threads in parallel:
4648
.sp
4749
.if n .RS 4
4850
.nf
@@ -678,6 +680,23 @@ cargo test
678680
. sp -1
679681
. IP " 2." 4.2
680682
.\}
683+
Run only tests whose names match against a filter string:
684+
.sp
685+
.if n .RS 4
686+
.nf
687+
cargo test name_filter
688+
.fi
689+
.if n .RE
690+
.RE
691+
.sp
692+
.RS 4
693+
.ie n \{\
694+
\h'-04' 3.\h'+01'\c
695+
.\}
696+
.el \{\
697+
. sp -1
698+
. IP " 3." 4.2
699+
.\}
681700
Run only a specific test within a specific integration test:
682701
.sp
683702
.if n .RS 4

0 commit comments

Comments
 (0)