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

Correcting many_boxes_long_lived test that incorrectly passes for BumpAllocator when run with cargo test -r #1369

Open
wants to merge 2 commits into
base: post-11
Choose a base branch
from

Conversation

Robert-M-Lucas
Copy link

BumpAllocator currently passes many_boxes_long_lived in release mode due to long_lived and the assert_eq being optimised away. Testing in release mode can be useful as it can make tests run faster overall, despite the longer compile time per test and ensures correct functionality when debug code isn't included.

@AtomicGamer9523
Copy link

Is BumpAllocator supposed to fail many_boxes_long_lived in debug mode ?
If so, then shouldn't the test be annotated as such ?
And if not, then is there any evidence that long_lived gets optimized away ?

@Robert-M-Lucas
Copy link
Author

@AtomicGamer9523 The BumpAllocator is meant to fail many_boxes_long_lived (as it does in debug mode when you are going through the tutorial) as long_lived prevents any freeing which it does not do in release mode with cargo test --release. While it is not the final allocator used, the BumpAllocator remains in the source code and its passing of this test shows that the test does not correctly test other allocators in release mode, something that I found useful to run tests faster (particularly when increasing the heap size).

@AtomicGamer9523
Copy link

Interesting, my main concern with black_box is this. There must be a better way to tell the compiler to not optimize out long_lived.

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

Successfully merging this pull request may close these issues.

2 participants