对货物使用多个标志
Using multiple flags with cargo
我想 运行 使用 1 个测试线程进行发布优化测试。
我可以单独完成这些:
cargo test -- --test-threads=1
cargo test --release
我怎么把它们放在一起?
您可以像这样在一个命令中同时使用两者:
cargo test --release -- --test-threads=1
Cargo 如何解释这些参数?
根据 reference 中测试子命令的概要:
cargo test [OPTIONS] [TESTNAME] [-- TEST-OPTIONS]
Cargo 将输入解释为:
分隔符 (--
) 之前的参数将用作 test
子命令的 选项 。在您的情况下,cargo test
接受配置文件参数作为 选项 ,因为它构建了项目。可以在 this title 或 运行 宁 cargo test --help
下找到可用的选项。
分隔符后的参数将传递给测试二进制文件。在 Rust 项目中,Cargo 使用 rustc
的 libtest 到 运行 单元测试。在你的例子中 --test-threads=1
将是 libtest
的参数。
此解释可能对其他子命令无效,最好查看 here 中的其他 cargo 命令。检查 概要 部分将为您提供有关 cargo
子命令功能的巨大提示。
另见:
- 由于破折号后的参数将被发送到
rustc's
libtest
您可以通过以下方式查看可用的测试选项:cargo test -- --help
.
- 配置文件选项可以在 this title
下找到
我想 运行 使用 1 个测试线程进行发布优化测试。
我可以单独完成这些:
cargo test -- --test-threads=1
cargo test --release
我怎么把它们放在一起?
您可以像这样在一个命令中同时使用两者:
cargo test --release -- --test-threads=1
Cargo 如何解释这些参数?
根据 reference 中测试子命令的概要:
cargo test [OPTIONS] [TESTNAME] [-- TEST-OPTIONS]
Cargo 将输入解释为:
分隔符 (
--
) 之前的参数将用作test
子命令的 选项 。在您的情况下,cargo test
接受配置文件参数作为 选项 ,因为它构建了项目。可以在 this title 或 运行 宁cargo test --help
下找到可用的选项。分隔符后的参数将传递给测试二进制文件。在 Rust 项目中,Cargo 使用
rustc
的 libtest 到 运行 单元测试。在你的例子中--test-threads=1
将是libtest
的参数。
此解释可能对其他子命令无效,最好查看 here 中的其他 cargo 命令。检查 概要 部分将为您提供有关 cargo
子命令功能的巨大提示。
另见:
- 由于破折号后的参数将被发送到
rustc's
libtest
您可以通过以下方式查看可用的测试选项:cargo test -- --help
. - 配置文件选项可以在 this title 下找到