flycheck / flycheck-rust

Better Rust/Cargo support for Flycheck

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integration tests are not checked

jsdir opened this issue · comments

commented

The integration tests in my Cargo project (tests/integration_test.rs) are not being checked on save.

flycheck-compile gives me:

cargo rustc --lib -- -Z no-trans -Z unstable-options --error-format\=json --test -L/home/me/libname/target/debug -L/home/me/libname/target/debug/deps

This command exits successfully even when there are errors in the integration tests. I don't know if this is an issue with flycheck-rust or flycheck.

Thanks for pointing this out.

As far as I understand, the files in tests won't be checked by the current command because cargo rustc --lib will only build the files needed by the library. If there are any #[test] functions in these files, they will be checked, but the files in tests are obviously not part of the library, so they won't be checked.

According to the rust book:

Each file in tests/*.rs directory is treated as individual crate

And indeed, running cargo read-manifest reports the files in tests/ as separate targets:

{
  "targets": [{
      "kind": ["bin"],
      "name": "flycheck",
      "src_path": "src/main.rs"
    },
    {
      "kind": ["test"],
      "name": "integration_test",
      "src_path": "tests/integration_test.rs"
    }

And it seems that neither flycheck-rust nor flycheck has code to handle a test crate, so might as well report it here :)

There's a simple fix, and then there's the right fix, which is to eat what read-manifest feeds us completly, and is related to #8. I lean towards the latter, so I'll see what I can do about that.

commented

Thanks for the quick response!