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

Add "invert_result" to test() option #14244

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

twied
Copy link

@twied twied commented Feb 12, 2025

This is very similar to "should_fail", but does not change the test results to "Expected Fail" / "Unexpected Pass".

"Expected Fail" and "Unexpected Pass" are useful when they communicate to developers that additional work needs to be done, e.g. as part of Test Driven Development or to demonstrate problems with some edge cases that need to be addressed in the future.

In other cases, a non-zero status code is actually the whole test, e.g. a program under test that is expected to exit with a non-zero status code when given invalid arguments or a bad configuration file. This is the expected behavior and hence should be reported as "Pass", not "Expected Fail".

"invert_result" and "should_fail" can be combined to produce "Unexpected Pass" for non-zero status codes and "Expected Fail" for zero status codes.

test(
    'fail if config file is missing',
    executable(...),
    args: [ '--config', '/path/does/not/exist' ],
    invert_result: true)

Tim Wiederhake added 2 commits February 12, 2025 11:41
"should_fail" does more than just reverse the meaning of zero vs
non-zero exit codes: It changes the test results from "Ok" and "Fail" to
"Expected Fail" and "Unexpected Pass". This should be mentioned in the
documentation.
This is very similar to "should_fail", but does not change the test
results to "Expected Fail" / "Unexpected Pass".

"invert_result" and "should_fail" can be combined to produce "Unexpected Pass"
for non-zero status codes and "Expected Fail" for zero status codes.
@twied twied requested a review from jpakkane as a code owner February 12, 2025 11:01
@bonzini
Copy link
Collaborator

bonzini commented Feb 12, 2025

Can you check if #13559 would work for you too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants