Cargo test cannot reference anything public inside the targeting crate in integration test. Unit tests also cannot find test cases

喜欢而已 提交于 2020-01-06 05:48:06

问题


I am trying to do some test on my no_std module but I cannot make both integration and unit test working. I think the cargo does not make functions and modules visible to others.

The project is at: https://github.com/ShisoftResearch/Nulloc/tree/e2e15646da79651ddb8c29e0526bad0d60690bec

Run cargo test, I got:

➜ cargo test
   Compiling nulloc v0.1.0 (/Users/shisoft/Dropbox/Code/OSS Projects/Nulloc)
error[E0432]: unresolved import `nulloc::bump_heap`
 --> tests/bump_heap.rs:3:14
  |
3 |  use nulloc::bump_heap::BumpAllocator;
  |              ^^^^^^^^^ could not find `bump_heap` in `nulloc`

error[E0432]: unresolved import `nulloc::bump_heap`
 --> tests/bump_heap.rs:3:14
  |
3 |  use nulloc::bump_heap::BumpAllocator;
  |              ^^^^^^^^^ could not find `bump_heap` in `nulloc`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `nulloc`.
warning: build failed, waiting for other jobs to finish...
error: could not compile `nulloc`.

To learn more, run the command again with --verbose.

But I have already extern the crate I am going to test in tests.rs and bump_heap have been marked as public in the lib.rs.

When I try to do run the unit test inside bump_heap.rs, cargo cannot find the test cases.

I am not sure what's going on here

来源:https://stackoverflow.com/questions/58441073/cargo-test-cannot-reference-anything-public-inside-the-targeting-crate-in-integr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!