spechter
spechter

Reputation: 2368

Cargo says "test failed, to rerun pass '--lib" - What does it mean?

What is cargo trying to tell me here with this final message? :

error: test failed, to rerun pass '--lib'

Even the Cargo book has test examples showing this exact final line, without explanation. It almost sounds like it is saying, "If you don't pass --lib, we won't rerun the tests" - Does it pull test results from a cache?

If I add "--lib" to my command line, thus: cargo test --features some_feature --lib, it doesn't seem to do anything special.

Doing some digging, I found a Cargo code change that seems to be trying to show "{pkg_info}--lib"

So, what is Cargo trying to tell me? Something meaningful, or is it just a bug that confuses new users?

Upvotes: 8

Views: 3873

Answers (1)

loops
loops

Reputation: 5635

That error message means that in order to rerun the tests that failed, you should pass --lib. What --lib does is (from the help) "Test only this package's library unit tests". So a library unit test failed, and Cargo is telling you how to rerun only the library unit tests, since you don't need to bother re-running the tests that just passed, but instead usually want to focus on the tests that failed and rerun those only.

Upvotes: 4

Related Questions