773 lines
20 KiB
HTML
773 lines
20 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of CARGO-TEST</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>CARGO-TEST</H1>
|
|
Section: (1)<BR>Updated: 2020-06-25<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
cargo-test - Execute unit and integration tests of a package
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<P>
|
|
<B>cargo test [</B><I>OPTIONS</I>] [TESTNAME] [-- <I>TEST-OPTIONS</I>]
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
Compile and execute unit and integration tests.
|
|
<P>
|
|
The test filtering argument <B>TESTNAME</B> and all the arguments following the two
|
|
dashes (<B>--</B>) are passed to the test binaries and thus to <I>libtest</I> (rustc's
|
|
built in unit-test and micro-benchmarking framework). If you're passing
|
|
arguments to both Cargo and the binary, the ones after <B>--</B> go to the binary,
|
|
the ones before go to Cargo. For details about libtest's arguments see the
|
|
output of <B>cargo test -- --help</B>. As an example, this will run all tests with
|
|
<B>foo</B> in their name on 3 threads in parallel:
|
|
<P>
|
|
<DL COMPACT><DT id="1"><DD>
|
|
|
|
<PRE>
|
|
cargo test foo -- --test-threads 3
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
<P>
|
|
Tests are built with the <B>--test</B> option to <B>rustc</B> which creates an
|
|
executable with a <B>main</B> function that automatically runs all functions
|
|
annotated with the <B>#[test]</B> attribute in multiple threads. <B>#[bench]</B>
|
|
annotated functions will also be run with one iteration to verify that they
|
|
are functional.
|
|
<P>
|
|
The libtest harness may be disabled by setting <B>harness = false</B> in the target
|
|
manifest settings, in which case your code will need to provide its own <B>main</B>
|
|
function to handle running tests.
|
|
<P>
|
|
Documentation tests are also run by default, which is handled by <B>rustdoc</B>. It
|
|
extracts code samples from documentation comments and executes them. See the
|
|
|
|
<I>rustdoc book</I> <<A HREF="https://doc.rust-lang.org/rustdoc/">https://doc.rust-lang.org/rustdoc/</A>>
|
|
|
|
for more information on
|
|
writing doc tests.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Test Options</H3>
|
|
|
|
<P>
|
|
<B>--no-run</B>
|
|
<DL COMPACT><DT id="2"><DD>
|
|
Compile, but don't run tests.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--no-fail-fast</B>
|
|
<DL COMPACT><DT id="3"><DD>
|
|
Run all tests regardless of failure. Without this flag, Cargo will exit
|
|
after the first executable fails. The Rust test harness will run all
|
|
tests within the executable to completion, this flag only applies to
|
|
the executable as a whole.
|
|
</DL>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Package Selection</H3>
|
|
|
|
<P>
|
|
By default, when no package selection options are given, the packages selected
|
|
depend on the selected manifest file (based on the current working directory if
|
|
<B>--manifest-path</B> is not given). If the manifest is the root of a workspace then
|
|
the workspaces default members are selected, otherwise only the package defined
|
|
by the manifest will be selected.
|
|
<P>
|
|
The default members of a workspace can be set explicitly with the
|
|
<B>workspace.default-members</B> key in the root manifest. If this is not set, a
|
|
virtual workspace will include all workspace members (equivalent to passing
|
|
<B>--workspace</B>), and a non-virtual workspace will include only the root crate itself.
|
|
<P>
|
|
<B>-p</B> <I>SPEC</I>..., <B>--package</B> <I>SPEC</I>...
|
|
<DL COMPACT><DT id="4"><DD>
|
|
Test only the specified packages. See <B><A HREF="/cgi-bin/man/man2html?1+cargo-pkgid">cargo-pkgid</A></B>(1) for the
|
|
SPEC format. This flag may be specified multiple times.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--workspace</B>
|
|
<DL COMPACT><DT id="5"><DD>
|
|
Test all members in the workspace.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--all</B>
|
|
<DL COMPACT><DT id="6"><DD>
|
|
Deprecated alias for <B>--workspace</B>.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--exclude</B> <I>SPEC</I>...
|
|
<DL COMPACT><DT id="7"><DD>
|
|
Exclude the specified packages. Must be used in conjunction with the
|
|
<B>--workspace</B> flag. This flag may be specified multiple times.
|
|
</DL>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Target Selection</H3>
|
|
|
|
<P>
|
|
When no target selection options are given, <B>cargo test</B> will build the
|
|
following targets of the selected packages:
|
|
<P>
|
|
<DL COMPACT><DT id="8"><DD>
|
|
•
|
|
|
|
|
|
lib — used to link with binaries, examples, integration tests, and doc tests
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="9"><DD>
|
|
•
|
|
|
|
|
|
bins (only if integration tests are built and required features are
|
|
available)
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="10"><DD>
|
|
•
|
|
|
|
|
|
examples — to ensure they compile
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="11"><DD>
|
|
•
|
|
|
|
|
|
lib as a unit test
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="12"><DD>
|
|
•
|
|
|
|
|
|
bins as unit tests
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="13"><DD>
|
|
•
|
|
|
|
|
|
integration tests
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="14"><DD>
|
|
•
|
|
|
|
|
|
doc tests for the lib target
|
|
</DL>
|
|
|
|
<P>
|
|
The default behavior can be changed by setting the <B>test</B> flag for the target
|
|
in the manifest settings. Setting examples to <B>test = true</B> will build and run
|
|
the example as a test. Setting targets to <B>test = false</B> will stop them from
|
|
being tested by default. Target selection options that take a target by name
|
|
ignore the <B>test</B> flag and will always test the given target.
|
|
<P>
|
|
Doc tests for libraries may be disabled by setting <B>doctest = false</B> for the
|
|
library in the manifest.
|
|
<P>
|
|
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 <B>CARGO_BIN_EXE_<name></B>
|
|
|
|
<I>environment variable</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates">https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates</A>>
|
|
|
|
is set when the integration test is built so that it can use the
|
|
|
|
<I><B>env</B> macro</I> <<A HREF="https://doc.rust-lang.org/std/macro.env.html">https://doc.rust-lang.org/std/macro.env.html</A>>
|
|
|
|
to locate the
|
|
executable.
|
|
<P>
|
|
Passing target selection flags will test only the
|
|
specified targets.
|
|
<P>
|
|
<B>--lib</B>
|
|
<DL COMPACT><DT id="15"><DD>
|
|
Test the package's library.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--bin</B> <I>NAME</I>...
|
|
<DL COMPACT><DT id="16"><DD>
|
|
Test the specified binary. This flag may be specified multiple times.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--bins</B>
|
|
<DL COMPACT><DT id="17"><DD>
|
|
Test all binary targets.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--example</B> <I>NAME</I>...
|
|
<DL COMPACT><DT id="18"><DD>
|
|
Test the specified example. This flag may be specified multiple times.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--examples</B>
|
|
<DL COMPACT><DT id="19"><DD>
|
|
Test all example targets.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--test</B> <I>NAME</I>...
|
|
<DL COMPACT><DT id="20"><DD>
|
|
Test the specified integration test. This flag may be specified multiple
|
|
times.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--tests</B>
|
|
<DL COMPACT><DT id="21"><DD>
|
|
Test all targets in test mode that have the <B>test = true</B> manifest
|
|
flag set. By default this includes the library and binaries built as
|
|
unittests, and integration tests. Be aware that this will also build any
|
|
required dependencies, so the lib target may be built twice (once as a
|
|
unittest, and once as a dependency for binaries, integration tests, etc.).
|
|
Targets may be enabled or disabled by setting the <B>test</B> flag in the
|
|
manifest settings for the target.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--bench</B> <I>NAME</I>...
|
|
<DL COMPACT><DT id="22"><DD>
|
|
Test the specified benchmark. This flag may be specified multiple times.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--benches</B>
|
|
<DL COMPACT><DT id="23"><DD>
|
|
Test all targets in benchmark mode that have the <B>bench = true</B>
|
|
manifest flag set. By default this includes the library and binaries built
|
|
as benchmarks, and bench targets. Be aware that this will also build any
|
|
required dependencies, so the lib target may be built twice (once as a
|
|
benchmark, and once as a dependency for binaries, benchmarks, etc.).
|
|
Targets may be enabled or disabled by setting the <B>bench</B> flag in the
|
|
manifest settings for the target.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--all-targets</B>
|
|
<DL COMPACT><DT id="24"><DD>
|
|
Test all targets. This is equivalent to specifying <B>--lib --bins
|
|
--tests --benches --examples</B>.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--doc</B>
|
|
<DL COMPACT><DT id="25"><DD>
|
|
Test only the library's documentation. This cannot be mixed with other
|
|
target options.
|
|
</DL>
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Feature Selection</H3>
|
|
|
|
<P>
|
|
The feature flags allow you to control the enabled features for the "current"
|
|
package. The "current" package is the package in the current directory, or the
|
|
one specified in <B>--manifest-path</B>. If running in the root of a virtual
|
|
workspace, then the default features are selected for all workspace members,
|
|
or all features if <B>--all-features</B> is specified.
|
|
<P>
|
|
When no feature options are given, the <B>default</B> feature is activated for
|
|
every selected package.
|
|
<P>
|
|
<B>--features</B> <I>FEATURES</I>
|
|
<DL COMPACT><DT id="26"><DD>
|
|
Space or comma separated list of features to activate. These features only
|
|
apply to the current directory's package. Features of direct dependencies
|
|
may be enabled with <B><dep-name>/<feature-name></B> syntax. This flag may be
|
|
specified multiple times, which enables all specified features.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--all-features</B>
|
|
<DL COMPACT><DT id="27"><DD>
|
|
Activate all available features of all selected packages.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--no-default-features</B>
|
|
<DL COMPACT><DT id="28"><DD>
|
|
Do not activate the <B>default</B> feature of the current directory's
|
|
package.
|
|
</DL>
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>Compilation Options</H3>
|
|
|
|
<P>
|
|
<B>--target</B> <I>TRIPLE</I>
|
|
<DL COMPACT><DT id="29"><DD>
|
|
Test for the given architecture. The default is the host
|
|
architecture. The general format of the triple is
|
|
<B><arch><sub>-<vendor>-<sys>-<abi></B>. Run <B>rustc --print target-list</B> for a
|
|
list of supported targets.
|
|
<P>
|
|
This may also be specified with the <B>build.target</B>
|
|
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
<P>
|
|
Note that specifying this flag makes Cargo run in a different mode where the
|
|
target artifacts are placed in a separate directory. See the
|
|
|
|
<I>build cache</I> <<A HREF="https://doc.rust-lang.org/cargo/guide/build-cache.html">https://doc.rust-lang.org/cargo/guide/build-cache.html</A>>
|
|
|
|
documentation for more details.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--release</B>
|
|
<DL COMPACT><DT id="30"><DD>
|
|
Test optimized artifacts with the <B>release</B> profile. See the
|
|
PROFILES section for details on how this affects profile selection.
|
|
</DL>
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H3>Output Options</H3>
|
|
|
|
<P>
|
|
<B>--target-dir</B> <I>DIRECTORY</I>
|
|
<DL COMPACT><DT id="31"><DD>
|
|
Directory for all generated artifacts and intermediate files. May also be
|
|
specified with the <B>CARGO_TARGET_DIR</B> environment variable, or the
|
|
<B>build.target-dir</B>
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
Defaults
|
|
to <B>target</B> in the root of the workspace.
|
|
</DL>
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H3>Display Options</H3>
|
|
|
|
<P>
|
|
By default the Rust test harness hides output from test execution to keep
|
|
results readable. Test output can be recovered (e.g., for debugging) by passing
|
|
<B>--nocapture</B> to the test binaries:
|
|
<P>
|
|
<DL COMPACT><DT id="32"><DD>
|
|
|
|
<PRE>
|
|
cargo test -- --nocapture
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
<P>
|
|
<B>-v</B>, <B>--verbose</B>
|
|
<DL COMPACT><DT id="33"><DD>
|
|
Use verbose output. May be specified twice for "very verbose" output which
|
|
includes extra output such as dependency warnings and build script output.
|
|
May also be specified with the <B>term.verbose</B>
|
|
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
<B>-q</B>, <B>--quiet</B>
|
|
<DL COMPACT><DT id="34"><DD>
|
|
No output printed to stdout.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--color</B> <I>WHEN</I>
|
|
<DL COMPACT><DT id="35"><DD>
|
|
Control when colored output is used. Valid values:
|
|
<P>
|
|
<DL COMPACT><DT id="36"><DD>
|
|
•
|
|
|
|
|
|
<B>auto</B> (default): Automatically detect if color support is available on the
|
|
terminal.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="37"><DD>
|
|
•
|
|
|
|
|
|
<B>always</B>: Always display colors.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="38"><DD>
|
|
•
|
|
|
|
|
|
<B>never</B>: Never display colors.
|
|
</DL>
|
|
|
|
<P>
|
|
May also be specified with the <B>term.color</B>
|
|
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--message-format</B> <I>FMT</I>
|
|
<DL COMPACT><DT id="39"><DD>
|
|
The output format for diagnostic messages. Can be specified multiple times
|
|
and consists of comma-separated values. Valid values:
|
|
<P>
|
|
<DL COMPACT><DT id="40"><DD>
|
|
•
|
|
|
|
|
|
<B>human</B> (default): Display in a human-readable text format.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="41"><DD>
|
|
•
|
|
|
|
|
|
<B>short</B>: Emit shorter, human-readable text messages.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="42"><DD>
|
|
•
|
|
|
|
|
|
<B>json</B>: Emit JSON messages to stdout. See
|
|
|
|
<I>the reference</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages">https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages</A>>
|
|
|
|
for more details.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="43"><DD>
|
|
•
|
|
|
|
|
|
<B>json-diagnostic-short</B>: Ensure the <B>rendered</B> field of JSON messages contains
|
|
the "short" rendering from rustc.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="44"><DD>
|
|
•
|
|
|
|
|
|
<B>json-diagnostic-rendered-ansi</B>: Ensure the <B>rendered</B> field of JSON messages
|
|
contains embedded ANSI color codes for respecting rustc's default color
|
|
scheme.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="45"><DD>
|
|
•
|
|
|
|
|
|
<B>json-render-diagnostics</B>: Instruct Cargo to not include rustc diagnostics in
|
|
in JSON messages printed, but instead Cargo itself should render the
|
|
JSON diagnostics coming from rustc. Cargo's own JSON diagnostics and others
|
|
coming from rustc are still emitted.
|
|
</DL>
|
|
|
|
</DL>
|
|
|
|
<A NAME="lbAM"> </A>
|
|
<H3>Manifest Options</H3>
|
|
|
|
<P>
|
|
<B>--manifest-path</B> <I>PATH</I>
|
|
<DL COMPACT><DT id="46"><DD>
|
|
Path to the <B>Cargo.toml</B> file. By default, Cargo searches for the
|
|
<B>Cargo.toml</B> file in the current directory or any parent directory.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--frozen</B>, <B>--locked</B>
|
|
<DL COMPACT><DT id="47"><DD>
|
|
Either of these flags requires that the <B>Cargo.lock</B> file is
|
|
up-to-date. If the lock file is missing, or it needs to be updated, Cargo will
|
|
exit with an error. The <B>--frozen</B> flag also prevents Cargo from
|
|
attempting to access the network to determine if it is out-of-date.
|
|
<P>
|
|
These may be used in environments where you want to assert that the
|
|
<B>Cargo.lock</B> file is up-to-date (such as a CI build) or want to avoid network
|
|
access.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>--offline</B>
|
|
<DL COMPACT><DT id="48"><DD>
|
|
Prevents Cargo from accessing the network for any reason. Without this
|
|
flag, Cargo will stop with an error if it needs to access the network and
|
|
the network is not available. With this flag, Cargo will attempt to
|
|
proceed without the network if possible.
|
|
<P>
|
|
Beware that this may result in different dependency resolution than online
|
|
mode. Cargo will restrict itself to crates that are downloaded locally, even
|
|
if there might be a newer version as indicated in the local copy of the index.
|
|
See the <B><A HREF="/cgi-bin/man/man2html?1+cargo-fetch">cargo-fetch</A></B>(1) command to download dependencies before going
|
|
offline.
|
|
<P>
|
|
May also be specified with the <B>net.offline</B>
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
</DL>
|
|
|
|
<A NAME="lbAN"> </A>
|
|
<H3>Common Options</H3>
|
|
|
|
<P>
|
|
<B>+TOOLCHAIN</B>
|
|
<DL COMPACT><DT id="49"><DD>
|
|
If Cargo has been installed with rustup, and the first argument to <B>cargo</B>
|
|
begins with <B>+</B>, it will be interpreted as a rustup toolchain name (such
|
|
as <B>+stable</B> or <B>+nightly</B>).
|
|
See the
|
|
<I>rustup documentation</I> <<A HREF="https://github.com/rust-lang/rustup/">https://github.com/rust-lang/rustup/</A>>
|
|
|
|
for more information about how toolchain overrides work.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>-h</B>, <B>--help</B>
|
|
<DL COMPACT><DT id="50"><DD>
|
|
Prints help information.
|
|
</DL>
|
|
|
|
<P>
|
|
<B>-Z</B> <I>FLAG</I>...
|
|
<DL COMPACT><DT id="51"><DD>
|
|
Unstable (nightly-only) flags to Cargo. Run <B>cargo -Z help</B> for
|
|
details.
|
|
</DL>
|
|
|
|
<A NAME="lbAO"> </A>
|
|
<H3>Miscellaneous Options</H3>
|
|
|
|
<P>
|
|
The <B>--jobs</B> argument affects the building of the test executable but does not
|
|
affect how many threads are used when running the tests. The Rust test harness
|
|
includes an option to control the number of threads used:
|
|
<P>
|
|
<DL COMPACT><DT id="52"><DD>
|
|
|
|
<PRE>
|
|
cargo test -j 2 -- --test-threads=2
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
<P>
|
|
<B>-j</B> <I>N</I>, <B>--jobs</B> <I>N</I>
|
|
<DL COMPACT><DT id="53"><DD>
|
|
Number of parallel jobs to run. May also be specified with the
|
|
<B>build.jobs</B>
|
|
<I>config value</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/config.html">https://doc.rust-lang.org/cargo/reference/config.html</A>>.
|
|
|
|
Defaults to
|
|
the number of CPUs.
|
|
</DL>
|
|
|
|
<A NAME="lbAP"> </A>
|
|
<H2>PROFILES</H2>
|
|
|
|
<P>
|
|
Profiles may be used to configure compiler options such as optimization levels
|
|
and debug settings. See
|
|
|
|
<I>the reference</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/profiles.html">https://doc.rust-lang.org/cargo/reference/profiles.html</A>>
|
|
|
|
for more details.
|
|
<P>
|
|
Profile selection depends on the target and crate being built. By default the
|
|
<B>dev</B> or <B>test</B> profiles are used. If the <B>--release</B> flag is given, then the
|
|
<B>release</B> or <B>bench</B> profiles are used.
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD>
|
|
<P>
|
|
Target
|
|
</TD><TD>
|
|
<P>
|
|
Default Profile
|
|
</TD><TD>
|
|
<P>
|
|
<B>--release</B> Profile
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<P>
|
|
lib, bin, example
|
|
</TD><TD>
|
|
<P>
|
|
<B>dev</B>
|
|
</TD><TD>
|
|
<P>
|
|
<B>release</B>
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<P>
|
|
test, bench, or any target
|
|
<BR>
|
|
|
|
in "test" or "bench" mode
|
|
</TD><TD>
|
|
<P>
|
|
<B>test</B>
|
|
</TD><TD>
|
|
<P>
|
|
<B>bench</B>
|
|
<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<P>
|
|
Dependencies use the <B>dev</B>/<B>release</B> profiles.
|
|
<P>
|
|
Unit tests are separate executable artifacts which use the <B>test</B>/<B>bench</B>
|
|
profiles. Example targets are built the same as with <B>cargo build</B> (using the
|
|
<B>dev</B>/<B>release</B> profiles) unless you are building them with the test harness
|
|
(by setting <B>test = true</B> in the manifest or using the <B>--example</B> flag) in
|
|
which case they use the <B>test</B>/<B>bench</B> profiles. Library targets are built
|
|
with the <B>dev</B>/<B>release</B> profiles when linked to an integration test, binary,
|
|
or doctest.
|
|
<A NAME="lbAQ"> </A>
|
|
<H2>ENVIRONMENT</H2>
|
|
|
|
<P>
|
|
See
|
|
<I>the reference</I> <<A HREF="https://doc.rust-lang.org/cargo/reference/environment-variables.html">https://doc.rust-lang.org/cargo/reference/environment-variables.html</A>>
|
|
|
|
for
|
|
details on environment variables that Cargo reads.
|
|
<A NAME="lbAR"> </A>
|
|
<H2>EXIT STATUS</H2>
|
|
|
|
<P>
|
|
0
|
|
<DL COMPACT><DT id="54"><DD>
|
|
Cargo succeeded.
|
|
</DL>
|
|
|
|
<P>
|
|
101
|
|
<DL COMPACT><DT id="55"><DD>
|
|
Cargo failed to complete.
|
|
</DL>
|
|
|
|
<A NAME="lbAS"> </A>
|
|
<H2>EXAMPLES</H2>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="56"><DD>
|
|
1.
|
|
|
|
|
|
Execute all the unit and integration tests of the current package:
|
|
<P>
|
|
<DL COMPACT><DT id="57"><DD>
|
|
|
|
<PRE>
|
|
cargo test
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="58"><DD>
|
|
2.
|
|
|
|
|
|
Run only a specific test within a specific integration test:
|
|
<P>
|
|
<DL COMPACT><DT id="59"><DD>
|
|
|
|
<PRE>
|
|
cargo test --test int_test_name -- modname::test_name
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
</DL>
|
|
|
|
<A NAME="lbAT"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<P>
|
|
<B><A HREF="/cgi-bin/man/man2html?1+cargo">cargo</A></B>(1), <B><A HREF="/cgi-bin/man/man2html?1+cargo-bench">cargo-bench</A></B>(1)
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="60"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="61"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="62"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="63"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DL>
|
|
<DT id="64"><A HREF="#lbAF">Test Options</A><DD>
|
|
<DT id="65"><A HREF="#lbAG">Package Selection</A><DD>
|
|
<DT id="66"><A HREF="#lbAH">Target Selection</A><DD>
|
|
<DT id="67"><A HREF="#lbAI">Feature Selection</A><DD>
|
|
<DT id="68"><A HREF="#lbAJ">Compilation Options</A><DD>
|
|
<DT id="69"><A HREF="#lbAK">Output Options</A><DD>
|
|
<DT id="70"><A HREF="#lbAL">Display Options</A><DD>
|
|
<DT id="71"><A HREF="#lbAM">Manifest Options</A><DD>
|
|
<DT id="72"><A HREF="#lbAN">Common Options</A><DD>
|
|
<DT id="73"><A HREF="#lbAO">Miscellaneous Options</A><DD>
|
|
</DL>
|
|
<DT id="74"><A HREF="#lbAP">PROFILES</A><DD>
|
|
<DT id="75"><A HREF="#lbAQ">ENVIRONMENT</A><DD>
|
|
<DT id="76"><A HREF="#lbAR">EXIT STATUS</A><DD>
|
|
<DT id="77"><A HREF="#lbAS">EXAMPLES</A><DD>
|
|
<DT id="78"><A HREF="#lbAT">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:08 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|