Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Peter-Darton-i2
Copy link
Contributor

Fixes #1180

...but I'd recommend that #1177 also be considered for merge at the same time; these seem related.

@Peter-Darton-i2 Peter-Darton-i2 requested a review from a team as a code owner December 11, 2025 17:02
Comment on lines +12 to +13
echo "normal teardown_suite fd3" >&3
echo "# Hash teardown_suite fd3" >&3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this PR, this output causes the last test in the suite to be falsely-flagged as a failure by the JUnit formatter.

name=non-empty reentrant_run -0 --separate-stderr bats --formatter junit "$FIXTURE_ROOT/issue1180"
[ "${stderr}" == "" ] || { echo "stderr should be empty but was: ${stderr}" >&3; return 1; }
[[ "${output}" != *'<failure '* ]]
[[ "${output}" == *'teardown_suite fd3'* ]]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the "tightest" of tests, but it seems to do the job.
The important thing is that there should be no failure elements if the bats tests passed.
A nice-to-have is to see the logged output in the report.

Comment on lines +247 to +248
local line="$1" scope="$2"
log_system_out "$line"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure of the wisdom of these two lines.

Comment on lines +77 to +83
if [[ "$test_result_state" == not_ok ]]; then # Failed tests need a <failure> element.
# If we have system err output, we use that as the failure text.
printf " <failure type=\"failure\">%s</failure>\n" "$(xml_escape "${_buffer_log}")"
else
if [[ -n "$_buffer_log" ]]; then
printf " <system-err>%s</system-err>\n" "$(xml_escape "${_buffer_log}")"
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core of my thinking here: only "not_ok" tests should report a <failure... element.
Everything else should say it's ok while recording as much of the test's output as system-out / system-err as possible.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JUnit-formatter outputs fail for skipped test ... sometimes

1 participant