简体   繁体   English

可以使用Cargo在发布模式下构建测试吗?

[英]Can tests be built in release mode using Cargo?

I'm using cargo build --release to build my project in release configuration and cargo test to build and run my tests. 我正在使用cargo build --release发布在发布配置和cargo test构建我的项目以构建和运行我的测试。

However, I'd like to also build my tests in release mode; 但是,我还想在发布模式下构建我的测试; can this be done using cargo? 这可以用货物完成吗?

cargo test --release exists, but it is slightly different than just enabling optimizations. cargo test --release存在,但它与仅启用优化略有不同。 For example, debug assertions become disabled. 例如,调试断言被禁用。

You can also set opt-level in the [profile.test] section of your Cargo.toml, as Viktor Dahl suggests . 您也可以在Cargo.toml [profile.test]部分设置opt-level正如Viktor Dahl建议的那样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM