diff --git a/src/doc/man/cargo-test.adoc b/src/doc/man/cargo-test.adoc index a4e6d80ed4c..32aa5ff6688 100644 --- a/src/doc/man/cargo-test.adoc +++ b/src/doc/man/cargo-test.adoc @@ -74,6 +74,14 @@ ignore the `test` flag and will always test the given target. Doc tests for libraries may be disabled by setting `doctest = false` for the library in the manifest. +Binary targets are automatically built if there is an integration test or +benchmark. This allows an integration test to execute the binary to exercise +and test its behavior. The `CARGO_BIN_EXE_` +linkcargo:reference/environment-variables.html#environment-variables-cargo-sets-for-crates[environment variable] +is set when the integration test is built so that it can use the +link:https://doc.rust-lang.org/std/macro.env.html[`env` macro] to locate the +executable. + include::options-targets.adoc[] *--doc*:: diff --git a/src/doc/man/generated/cargo-test.html b/src/doc/man/generated/cargo-test.html index faa7ee72292..bbf162dc88f 100644 --- a/src/doc/man/generated/cargo-test.html +++ b/src/doc/man/generated/cargo-test.html @@ -154,6 +154,15 @@

Target Selection

library in the manifest.

+

Binary targets are automatically built if there is an integration test or +benchmark. This allows an integration test to execute the binary to exercise +and test its behavior. The CARGO_BIN_EXE_<name> +environment variable +is set when the integration test is built so that it can use the +env macro to locate the +executable.

+
+

Passing target selection flags will test only the specified targets.

diff --git a/src/doc/src/reference/cargo-targets.md b/src/doc/src/reference/cargo-targets.md index 4be13c3529f..ebff8be475d 100644 --- a/src/doc/src/reference/cargo-targets.md +++ b/src/doc/src/reference/cargo-targets.md @@ -123,6 +123,15 @@ modules. The libtest harness will automatically find all of the `#[test]` annotated functions and run them in parallel. You can pass module names to [`cargo test`] to only run the tests within that module. +Binary targets are automatically built if there is an integration test. This +allows an integration test to execute the binary to exercise and test its +behavior. The `CARGO_BIN_EXE_` [environment variable] is set when the +integration test is built so that it can use the [`env` macro] to locate the +executable. + +[environment variable]: environment-variables.md#environment-variables-cargo-sets-for-crates +[`env` macro]: ../../std/macro.env.html + ### Benchmarks Benchmarks provide a way to test the performance of your code using the diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index 6ba68c6ae7a..bfd973a7932 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -195,7 +195,7 @@ let version = env!("CARGO_PKG_VERSION"); Binaries are automatically built when the test is built, unless the binary has required features that are not enabled. -[integration test]: manifest.md#integration-tests +[integration test]: cargo-targets.md#integration-tests [`env` macro]: ../../std/macro.env.html #### Dynamic library paths diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1 index 26a0aebf6bd..4ebb9def95f 100644 --- a/src/etc/man/cargo-test.1 +++ b/src/etc/man/cargo-test.1 @@ -2,12 +2,12 @@ .\" Title: cargo-test .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.10 -.\" Date: 2020-01-18 +.\" Date: 2020-02-06 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-TEST" "1" "2020-01-18" "\ \&" "\ \&" +.TH "CARGO\-TEST" "1" "2020-02-06" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -206,6 +206,16 @@ ignore the \fBtest\fP flag and will always test the given target. Doc tests for libraries may be disabled by setting \fBdoctest = false\fP for the library in the manifest. .sp +Binary targets are automatically built if there is an integration test or +benchmark. This allows an integration test to execute the binary to exercise +and test its behavior. The \fBCARGO_BIN_EXE_\fP +\c +.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html#environment\-variables\-cargo\-sets\-for\-crates" "environment variable" +is set when the integration test is built so that it can use the +.URL "https://doc.rust\-lang.org/std/macro.env.html" "\fBenv\fP macro" " " +to locate the +executable. +.sp Passing target selection flags will test only the specified targets. .sp