Skip to content

Commit dd8841f

Browse files
committed
Rephrase wordings in testing docs
- Rephrase doctest exec model as "not guranteed and may change" instead - Mention `#[bench]` in what cargo-bench automatically runs - Make it clear for build/rustc when mentioning bin targets auto-built
1 parent fc6b3cc commit dd8841f

15 files changed

+63
-54
lines changed

src/doc/man/cargo-bench.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ similarly named benchmarks like `foobar`):
3030

3131
Benchmarks are built with the `--test` option to `rustc` which creates a
3232
special executable by linking your code with libtest. The executable
33-
automatically runs all functions annotated with the `#[test]` attribute.
34-
Cargo passes the `--bench` flag to the test harness to tell it to run only
35-
benchmarks.
33+
automatically runs all functions annotated with `#[test]` and `#[bench]`
34+
attributes. Cargo passes the `--bench` flag to the test harness to tell
35+
it to run only benchmarks.
3636

3737
The libtest harness may be disabled by setting `harness = false` in the target
3838
manifest settings, in which case your code will need to provide its own `main`

src/doc/man/cargo-test.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ extracts code samples from documentation comments of the library target, and
4747
then executes them.
4848

4949
Different from normal test targets, each code block compiles to a doctest
50-
executable on the fly with `rustc`. These executables runs in parallel in
50+
executable on the fly with `rustc`. These executables run in parallel in
5151
separate processes. The compilation of a code block is in fact a part of test
5252
function controlled by libtest, so some options such as `--jobs` might not
53-
take effect. Note that this execution model of doctests is an undocumented
54-
implementation details, beware of depending on it.
53+
take effect. Note that this execution model of doctests is not guaranteed
54+
and may change in the future; beware of depending on it.
5555

5656
See the [rustdoc book](https://doc.rust-lang.org/rustdoc/) for more information
5757
on writing doc tests.

src/doc/man/generated_txt/cargo-bench.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ DESCRIPTION
2525

2626
Benchmarks are built with the --test option to rustc which creates a
2727
special executable by linking your code with libtest. The executable
28-
automatically runs all functions annotated with the #[test] attribute.
29-
Cargo passes the --bench flag to the test harness to tell it to run only
30-
benchmarks.
28+
automatically runs all functions annotated with #[test] and #[bench]
29+
attributes. Cargo passes the --bench flag to the test harness to tell it
30+
to run only benchmarks.
3131

3232
The libtest harness may be disabled by setting harness = false in the
3333
target manifest settings, in which case your code will need to provide
@@ -119,9 +119,9 @@ OPTIONS
119119
benchmark the given target.
120120

121121
Binary targets are automatically built if there is an integration test
122-
or benchmark. This allows an integration test to execute the binary to
123-
exercise and test its behavior. The CARGO_BIN_EXE_<name> environment
124-
variable
122+
or benchmark being selected to benchmark. This allows an integration
123+
test to execute the binary to exercise and test its behavior. The
124+
CARGO_BIN_EXE_<name> environment variable
125125
<https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates>
126126
is set when the integration test is built so that it can use the env
127127
macro <https://doc.rust-lang.org/std/macro.env.html> to locate the

src/doc/man/generated_txt/cargo-build.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ OPTIONS
5252
skipped if they have required-features that are missing.
5353

5454
Binary targets are automatically built if there is an integration test
55-
or benchmark. This allows an integration test to execute the binary to
56-
exercise and test its behavior. The CARGO_BIN_EXE_<name> environment
57-
variable
55+
or benchmark being selected to build. This allows an integration test to
56+
execute the binary to exercise and test its behavior. The
57+
CARGO_BIN_EXE_<name> environment variable
5858
<https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates>
5959
is set when the integration test is built so that it can use the env
6060
macro <https://doc.rust-lang.org/std/macro.env.html> to locate the

src/doc/man/generated_txt/cargo-rustc.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ OPTIONS
4343
binary and library targets of the selected package.
4444

4545
Binary targets are automatically built if there is an integration test
46-
or benchmark. This allows an integration test to execute the binary to
47-
exercise and test its behavior. The CARGO_BIN_EXE_<name> environment
48-
variable
46+
or benchmark being selected to build. This allows an integration test to
47+
execute the binary to exercise and test its behavior. The
48+
CARGO_BIN_EXE_<name> environment variable
4949
<https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates>
5050
is set when the integration test is built so that it can use the env
5151
macro <https://doc.rust-lang.org/std/macro.env.html> to locate the

src/doc/man/generated_txt/cargo-test.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ DESCRIPTION
4242
library target, and then executes them.
4343

4444
Different from normal test targets, each code block compiles to a
45-
doctest executable on the fly with rustc. These executables runs in
45+
doctest executable on the fly with rustc. These executables run in
4646
parallel in separate processes. The compilation of a code block is in
4747
fact a part of test function controlled by libtest, so some options such
4848
as --jobs might not take effect. Note that this execution model of
49-
doctests is an undocumented implementation details, beware of depending
50-
on it.
49+
doctests is not guaranteed and may change in the future; beware of
50+
depending on it.
5151

5252
See the rustdoc book <https://doc.rust-lang.org/rustdoc/> for more
5353
information on writing doc tests.
@@ -130,9 +130,9 @@ OPTIONS
130130
the library in the manifest.
131131

132132
Binary targets are automatically built if there is an integration test
133-
or benchmark. This allows an integration test to execute the binary to
134-
exercise and test its behavior. The CARGO_BIN_EXE_<name> environment
135-
variable
133+
or benchmark being selected to test. This allows an integration test to
134+
execute the binary to exercise and test its behavior. The
135+
CARGO_BIN_EXE_<name> environment variable
136136
<https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates>
137137
is set when the integration test is built so that it can use the env
138138
macro <https://doc.rust-lang.org/std/macro.env.html> to locate the

src/doc/man/includes/options-targets-bin-auto-built.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Binary targets are automatically built if there is an integration test or
2-
benchmark. This allows an integration test to execute the binary to exercise
3-
and test its behavior. The `CARGO_BIN_EXE_<name>`
2+
benchmark being selected to {{lower actionverb}}. This allows an integration
3+
test to execute the binary to exercise and test its behavior.
4+
The `CARGO_BIN_EXE_<name>`
45
[environment variable](../reference/environment-variables.html#environment-variables-cargo-sets-for-crates)
56
is set when the integration test is built so that it can use the
67
[`env` macro](https://doc.rust-lang.org/std/macro.env.html) to locate the

src/doc/src/commands/cargo-bench.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ similarly named benchmarks like `foobar`):
3030

3131
Benchmarks are built with the `--test` option to `rustc` which creates a
3232
special executable by linking your code with libtest. The executable
33-
automatically runs all functions annotated with the `#[test]` attribute.
34-
Cargo passes the `--bench` flag to the test harness to tell it to run only
35-
benchmarks.
33+
automatically runs all functions annotated with `#[test]` and `#[bench]`
34+
attributes. Cargo passes the `--bench` flag to the test harness to tell
35+
it to run only benchmarks.
3636

3737
The libtest harness may be disabled by setting `harness = false` in the target
3838
manifest settings, in which case your code will need to provide its own `main`
@@ -140,8 +140,9 @@ target by name ignore the `bench` flag and will always benchmark the given
140140
target.
141141

142142
Binary targets are automatically built if there is an integration test or
143-
benchmark. This allows an integration test to execute the binary to exercise
144-
and test its behavior. The `CARGO_BIN_EXE_<name>`
143+
benchmark being selected to benchmark. This allows an integration
144+
test to execute the binary to exercise and test its behavior.
145+
The `CARGO_BIN_EXE_<name>`
145146
[environment variable](../reference/environment-variables.html#environment-variables-cargo-sets-for-crates)
146147
is set when the integration test is built so that it can use the
147148
[`env` macro](https://doc.rust-lang.org/std/macro.env.html) to locate the

src/doc/src/commands/cargo-build.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ binary and library targets of the selected packages. Binaries are skipped if
6767
they have `required-features` that are missing.
6868

6969
Binary targets are automatically built if there is an integration test or
70-
benchmark. This allows an integration test to execute the binary to exercise
71-
and test its behavior. The `CARGO_BIN_EXE_<name>`
70+
benchmark being selected to build. This allows an integration
71+
test to execute the binary to exercise and test its behavior.
72+
The `CARGO_BIN_EXE_<name>`
7273
[environment variable](../reference/environment-variables.html#environment-variables-cargo-sets-for-crates)
7374
is set when the integration test is built so that it can use the
7475
[`env` macro](https://doc.rust-lang.org/std/macro.env.html) to locate the

src/doc/src/commands/cargo-rustc.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ When no target selection options are given, `cargo rustc` will build all
5454
binary and library targets of the selected package.
5555

5656
Binary targets are automatically built if there is an integration test or
57-
benchmark. This allows an integration test to execute the binary to exercise
58-
and test its behavior. The `CARGO_BIN_EXE_<name>`
57+
benchmark being selected to build. This allows an integration
58+
test to execute the binary to exercise and test its behavior.
59+
The `CARGO_BIN_EXE_<name>`
5960
[environment variable](../reference/environment-variables.html#environment-variables-cargo-sets-for-crates)
6061
is set when the integration test is built so that it can use the
6162
[`env` macro](https://doc.rust-lang.org/std/macro.env.html) to locate the

0 commit comments

Comments
 (0)