-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo check --tests not working #4330
Labels
Comments
ehuss
added a commit
to ehuss/cargo
that referenced
this issue
Oct 15, 2017
- Add `--profile test` flag to `cargo check` that will enable checking of unit tests. - `--tests` will implicitly enable checking of unit tests within the lib. - Don't implicitly compile binaries when using just `--test` filters. - Fix erroneously linking tests when run with `--test`. Fixes rust-lang#3431, rust-lang#4003, rust-lang#4059, rust-lang#4330.
bors
added a commit
that referenced
this issue
Oct 30, 2017
Add unit test checking to `cargo check` This is an extension of PR #4039, fixing #3431, #4003, #4059, #4330. The fixes for #4059 can potentially be separated into a separate PR, though there may be some overlap. The general gist of the changes: - Add `--profile test` flag to `cargo check` that will enable checking of unit tests. - `--tests` will implicitly enable checking of unit tests within the lib (checks the same targets as `cargo test`). This affects the `check`, `test`, and `build` commands. - `--benches` behaves similarly by using the same targets as `cargo bench`. - Fix erroneously linking tests when run with `--test`. There is one thing I did not do because I wanted more feedback on what others think the expected behavior should be. What should the behavior of `--all-targets` be? This patch does not (yet) make any changes to its behavior. My initial thinking is that it should *add* a target of `--lib --bins --profile test`, but that essentially means the lib and bin targets will be checked twice (and thus any errors/warnings outside of `#[cfg(test)]` will appear twice, which may be confusing, and generally take twice as long to run). I can add that, but I think it would require adding a new `All` variant to `CompileFilter` so that the code in `generate_targets` can detect this scenario. I wanted feedback before making a more extensive change like that. The downside of not adding it is that `--all-targets` will ignore unit tests (if you don't specify `--profile test`). Summary of the profiles used with this patch: Command | Lib | Bin foo | Test t1 | Example e1 | Bench b1 | ------- | --- | ------- | ------- | ---------- | -------- | `check` | check | check | - | - | - | `check --profile test` | check_test† | check_test† | - | - | - | `check --lib` | check | - | - | - | - | `check --lib --profile test` | check_test† | - | - | - | - | `check --bin foo` | check | check | - | - | - | `check -–bin foo –profile test` | check_test† | check_test† | - | - | - | `check --bins` | check | check | - | - | - | `check --test t1` | check | check | check_test | - | - | `check --tests` | check, check_test† | check, check_test† | check_test | check†, check_test† | - | `check --all-targets` | check, check_test† | check, check_test† | check_test | check, check_test† | check_test | † = different behavior from today
This is fixed by #4592. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cargo check --help
tellsI expect that at least it cheks syntax of tests.
I created simple project
cargo new foo
,and edit
src/lib.rs
like this:I run
cargo check --tests
(cargo 0.22.0-nightly (88aa6423a 2017-07-22)
) andit reports nothing:
I expected the same error report from
cargo check --tests
as fromcargo test
foo directory in attachment.
foo.zip
The text was updated successfully, but these errors were encountered: