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

request: support should_panic for #[test] functions #653

Open
Roba1993 opened this issue Oct 31, 2023 · 3 comments
Open

request: support should_panic for #[test] functions #653

Roba1993 opened this issue Oct 31, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Roba1993
Copy link
Contributor

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 udoprog added the enhancement New feature or request label Oct 31, 2023
@udoprog
Copy link
Collaborator

udoprog commented Oct 31, 2023

This is already supported for doc tests btw.

@Roba1993
Copy link
Contributor Author

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
Copy link
Collaborator

udoprog commented Oct 31, 2023

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.

@udoprog udoprog changed the title Support should_panic for rune tests request: support should_panic for #[test] functions Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants