request: support should_panic for #[test] functions
Roba1993 opened this issue · 3 comments
Roba1993 commented
Allow should panic flag for rune test functions like this:
#[test]
#[should_panic]
pub fn test() {
let object = #{ field: 1 };
let object2 = object;
println!("field: {}", object.field);
// move the variable into the drop function and consume it
drop(object2);
// This will fail
println!("field: {}", object.field);
}
udoprog commented
This is already supported for doc tests btw.
Roba1993 commented
This is already supported for doc tests btw.
Yeah I have seen that. My problem is for our documentation with Zola (non API documentation) I load scripts from a file. This allows me to test them and use them in the documentation in parallel.
See an example here: Exolynk Documentation
For that I need to explain the should_panic within the rune script itself.
udoprog commented
Yeah, totally understandable. This should be fairly easy to add since the infrastructure is mostly already in place. We just need to parse the attribute and propagate it out with how the test functions are collected.