feat(test): Support expected-failure tests via should_fail option#6588
Merged
waruqi merged 3 commits intoxmake-io:devfrom Jun 26, 2025
Merged
feat(test): Support expected-failure tests via should_fail option#6588waruqi merged 3 commits intoxmake-io:devfrom
waruqi merged 3 commits intoxmake-io:devfrom
Conversation
This patch adds support for marking test cases as expected to fail using the should_fail option in add_tests(). This is useful for validating crash handling, incomplete features, or contract-breaking behavior in a controlled manner. The test report has also been slightly modified to: - Distinguish expected failures and unexpected passes. - Print a detailed summary of failed tests, unexpected passes, and expected failures at the end.
waruqi
reviewed
Jun 25, 2025
xmake/actions/test/main.lua
Outdated
| passed_rate, report.total - report.passed, report.total, spent / 1000) | ||
|
|
||
| -- Print the summary | ||
| local summary = string.format("\n${color.success}%d%%%%${clear} tests passed, ${color.failure}%d${clear} test(s) failed", passed_rate, #failed_tests) |
Member
There was a problem hiding this comment.
we should move this summary to the last line.
Detailed summary:
Failed tests:
- test_11/compile_pass
- test_5/fail_output
- test_5/pass_output
- test_7/args
- test_7/default
- test_7/fail_output
- test_7/pass_output
- test_8/pass_output
- test_timeout/run_timeout
78% tests passed, 9 test(s) failed out of 42, spent 1.217s
Contributor
Author
There was a problem hiding this comment.
Done. I've updated the documentation accordingly. As for the failing pipeline jobs, I'm not quite sure if I introduced the issue, but I'd guess it's about the opt.errors manipulation in _do_test_target.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds support for marking test cases as expected to fail using the should_fail option in add_tests(). This is useful for validating crash handling, incomplete features, or contract-breaking behavior in a controlled manner.
The test report has also been slightly modified to:
Documentation PR: xmake-io/xmake-docs#230