I want to test one of my function that should panic, but my GitHub action abort()
cause even if my code is asking for "only" 2**31
bytes (In my real code the limit is libc::c_int::MAX
) that my PC has, GitHub action don't have such memory :p.
#[test]
#[should_panic]
fn reserve_with_max() {
Vec::with_capacity(usize::MAX);
}
But this fails with:
test tests::bad_fd ... ok
test tests::create_true ... ok
test tests::create_false ... ok
test tests::create_with_one ... ok
memory allocation of 25769803764 bytes failed
And this stops the testing and report an error, even if this what I expected (either panic or abort).
I didn't find much about this problem:
I expect there should be a #[should_abort]
, how could I handle this ?
For now my obvious solution is to ignore
the test:
#[test]
#[should_panic]
#[ignore = "Ask too much memory"]
There is an RFC 2116 that would allow to configure rust to make out of memory panic instead of abort()
:
[profile.dev]
oom = "panic"
[profile.release]
oom = "panic"
Cons:
abort()
in test.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With