Description
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 tosrc
- 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-af4564015b61948erunning 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, found123
--> src/lib.rs:2:8
|
3 | Input: 123
| ^^^ expecting a type here because of type ascriptiontest 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-af4564015b61948erunning 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) ... oktest 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)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status