Test
Execute unit and integration tests of a package
SYNOPSIS
cargo test [options] [testname] [-- test-executor-args...]
DESCRIPTION
Compile and execute unit and integration tests.
This command is equivalent to running buck2 test manually, but provides options that are semantically compatible with Cargo.
The test filter argument TESTNAME and related options are translated into appropriate Buck2 target labels, while arguments following the double dash (--) are passed directly to Buck2 as test executor arguments. The Buck2 test executor is expected to have --env flag to pass environment variables, which can be used like this:
cargo buckal test foo -- --env PRIVATE_KEY=123OPTIONS
-p, --package <SPEC>Test only the specified packages. This flag may be specified multiple times and supports common Unix glob patterns like*,?and[]. However, to avoid your shell accidentally expanding glob patterns before Cargo handles them, you must use single quotes or double quotes around each pattern.--workspaceTest all members in the workspace.--exclude <SPEC>Exclude the specified packages. Must be used in conjunction with the--workspaceflag. This flag may be specified multiple times and supports common Unix glob patterns like*,?and[]. However, to avoid your shell accidentally expanding glob patterns before Cargo handles them, you must use single quotes or double quotes around each pattern.--all-targetsTest all targets. This is equivalent to invokingbuck2 test cell//path/to/package/....--libTest the package’s library.--bin <NAME>Test the specified binary. This flag may be specified multiple times and supports common Unix glob patterns.--binsTest all binary targets.--example <NAME>Test the specified example. This flag may be specified multiple times and supports common Unix glob patterns.--examplesTest all example targets.--test <NAME>Test the specified integration test. This flag may be specified multiple times and supports common Unix glob patterns.--testsTest all targets that have thetest = truemanifest 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.).--no-runCompile, but don’t run tests.--no-fail-fastRun all tests regardless of failure.-j, --jobs <N>Number of threads to use during execution. Defaults to the number of logical CPUs.--target <TRIPLE>Test for the specified target architecture. Flag may be specified multiple times. The default is the host architecture.-r, --releaseTest optimized artifacts with thereleaseprofile.