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

unresolved imports in tests #138

Closed
Geal opened this issue Nov 23, 2020 · 2 comments
Closed

unresolved imports in tests #138

Geal opened this issue Nov 23, 2020 · 2 comments

Comments

@Geal
Copy link

Geal commented Nov 23, 2020

hello, when I try to use the new ctest feature, I get compilation errors if I have other tests in the tests/ directory.

How to reproduce: create example-project/tests/other.rs with the following content:

use example_project::OddCounter;

#[test]
fn test() {
}

When I run cargo test, that integration test is compiled and runs fine, but when I run cargo ctest, I get this error:

error[E0432]: unresolved import `example_project`
 --> tests/other.rs:1:5
  |
1 | use example_project::OddCounter;
  |     ^^^^^^^^^^^^^^^ use of undeclared crate or module `example_project`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
Error: CliError { error: Some(could not compile `example-project`

is it changing the crate name?

@lu-zero
Copy link
Owner

lu-zero commented Nov 23, 2020

I'll look at it now, the test reuses the context used by build, and that one does not have the rlib among its targets. Let me see if that's the problem.

@lu-zero
Copy link
Owner

lu-zero commented Nov 23, 2020

It was, also I discovered that expecting all linkers to implement -l:{filename} is too strong. I ended up force-feeding the .a itself to the compiler. Hopefully that works well enough for everybody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants