Skip to content
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

Diagnostics doesn't see the test crate #7252

Closed
boozook opened this issue Jan 12, 2021 · 2 comments
Closed

Diagnostics doesn't see the test crate #7252

boozook opened this issue Jan 12, 2021 · 2 comments
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@boozook
Copy link

boozook commented Jan 12, 2021

Diagnostics for benches partially broken, error:

  • unresolved extern crate
  • unresolved import

Steps to reproduce:

  1. new crate
  2. crate/benches/mybench.rs with source:
#![cfg(test)]
#![feature(test)]
extern crate test;                     // unresolved extern crate
use self::test::{Bencher, black_box};  // unresolved import

Screenshot 2021-01-12 at 10 33 34

@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Jan 12, 2021
@Zageron
Copy link

Zageron commented Jan 28, 2021

Well I dug into the code, and also tried writing a test but I couldn't get it to pass or fail as I expected.
There doesn't seem to be a way to assert that there are no problems with a diagnostic check, so I tried to fail something. But the result I get back is just empty. So yeah, not sure how to approach this.

#[test]
fn unresolved_extern_crate_test() {
    mark::check!(unresolved_extern_crate_test);
    check_diagnostics(
        r"
        #![cfg(test)]
        #![feature(test)]
        extern crate test;
          extern crate doesnotexist;
        //^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved extern crate
        ",
    )
}
running 2 tests
test nameres::tests::diagnostics::unresolved_extern_crate_test ... FAILED
test nameres::tests::diagnostics::unresolved_extern_crate ... ok

failures:

---- nameres::tests::diagnostics::unresolved_extern_crate_test stdout ----
thread 'nameres::tests::diagnostics::unresolved_extern_crate_test' panicked at 'assertion failed: `(left == right)`
  left: `{FileId(0): [(53..79, "unresolved extern crate")]}`,
 right: `{}`', crates\hir_def\src\test_db.rs:180:9

@Zageron
Copy link

Zageron commented Jan 28, 2021

#6714 same issue

@lnicola lnicola closed this as completed Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

3 participants