可以使用 Cargo 在发布模式下构建测试吗? [英] Can tests be built in release mode using Cargo?
本文介绍了可以使用 Cargo 在发布模式下构建测试吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 cargo build --release
在发布配置中构建我的项目,并使用 cargo test
构建和运行我的测试.
I'm using cargo build --release
to build my project in release configuration and cargo test
to build and run my tests.
但是,我还想在发布模式下构建我的测试;这可以使用货物来完成吗?
However, I'd like to also build my tests in release mode; can this be done using cargo?
推荐答案
cargo test --release
存在,但与仅启用优化略有不同.例如,调试断言被禁用.
cargo test --release
exists, but it is slightly different than just enabling optimizations. For example, debug assertions become disabled.
您还可以在 opt-level="noreferrer">您的 Cargo.toml 的 [profile.test]
部分,正如维克多·达尔所建议的.
You can also set opt-level
in the [profile.test]
section of your Cargo.toml, as Viktor Dahl suggests.
这篇关于可以使用 Cargo 在发布模式下构建测试吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文