Problem
cargo test -- --nocapture outputs error logs for documentation tests even when specifying the compile_fail argument.
Steps
- Create a new project with
cargo new <project name>
- Add a
lib.rs file to src
- Add the following method with documentation and code example which is supposed to fail compilation (the section code will contain invalid Rust code):
/// ```compile_fail
/// Input: 123
/// ```
pub fn foo() {
}
- Run
cargo test -- --nocapture
The output will be:
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running target/debug/deps/compile_fail-af4564015b61948e
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/compile_fail-8c19ede40c69c8ad
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests compile-fail
running 1 test
error: expected type, found 123
--> src/lib.rs:2:8
|
3 | Input: 123
| ^^^ expecting a type here because of type ascription
test src/lib.rs - foo (line 1) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Notes
Running cargo test presents a different output with no errors:
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running target/debug/deps/compile_fail-af4564015b61948e
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/compile_fail-8c19ede40c69c8ad
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests compile-fail
running 1 test
test src/lib.rs - foo (line 1) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Output of cargo version:
cargo 1.30.0 (36d96825d 2018-10-24)
Problem
cargo test -- --nocaptureoutputs error logs for documentation tests even when specifying thecompile_failargument.Steps
cargo new <project name>lib.rsfile tosrccargo test -- --nocaptureThe output will be:
Notes
Running
cargo testpresents a different output with no errors:Output of
cargo version: