Closed
Description
Cargo version: cargo 0.19.0-nightly (fa7584c14 2017-04-26)
cargo check --tests
and cargo build --tests
seem to ignore semantic errors in tests.
I don't know if that's intentional, but it's frustrating to be unable to cargo check
code in my tests properly.
Examples:
Common Cargo.toml
[package]
name = "check_test"
version = "0.1.0"
authors = ["me"]
[dependencies]
src/lib.rs
example 1
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
asset_eq!(1, 1); // intentional typo (semantic error)
}
}
What happens: running cargo check --lib --tests
completes with no errors (code 0)
What should happen: running cargo check --lib --tests
should indicate:
cannot find macro `asset_eq!` in this scope
help: did you mean `assert_eq!`?
src/lib.rs
example 2
fn not_a_test() {
asset_eq!(1, 1); // intentional typo (semantic error)
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
}
}
What happens AND should happen: running cargo check --lib --tests
indicates:
cannot find macro `asset_eq!` in this scope
help: did you mean `assert_eq!`?
src/lib.rs
example 3
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
i'm syntaxically incorrect code
}
}
What happens AND should happen: running cargo check --lib --tests
(actually cargo check
gives the same output, so I think that syntax is checked regardless of cargo filters) indicates:
message: 'expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `'m`
label: expected one of 8 possible tokens here'