Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reading about dead code problems in tests, multiple people pointed to this blog post.
The issue is, cargo compiles a single binary for each test suite. When you try to share code across suites, the checking is done at a per-suite level.
For example, you have:
If only one.rs uses
shared_fn()
, cargo test will complain that it's unused, because it's not used in all created binaries.Moving all the test modules into a
integrations/main.rs
forces a single binary to be compiled, which has the same type of dead code checking as a regular application.I also did some timing tests to make sure it didn't make anything slower. This was done running only the
mobile_verifier
workspace.time
was used to get timing forcargo test
, the built in timer was used forcargo nextest
.Running tests back to back, the first pass tended to be the faster by about 10 seconds. So take some of these numbers with a grain of salt. Also running on a
2.3 GHz 8-Core Intel Core i9
.Thoughts
the reproducibility of the test timing is finicky at best, but the tests do not get slow to the point where I feel it outweighs the benefits we can get from changing to this testing structure.
The main benefit being more reliable code re-use in our tests, and not needing to mark
#[allow(dead_code)]
for shared functions that are not used in every test suite.