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

Catch2: fix multiple section failures #112

Merged
merged 6 commits into from
Sep 8, 2023

Conversation

jnewb1
Copy link
Collaborator

@jnewb1 jnewb1 commented Sep 8, 2023

catch2 seems to return an exit code corresponding to the number of tests that fail when using the "SECTION" parameter

@jnewb1 jnewb1 force-pushed the catch2-fix-section branch from fa73526 to 9ce8ba8 Compare September 8, 2023 05:10
@jnewb1 jnewb1 force-pushed the catch2-fix-section branch from d03166c to 73cdc7f Compare September 8, 2023 05:29
@jnewb1 jnewb1 changed the title Catch2: fix sections Catch2: fix multiple section failures Sep 8, 2023
Comment on lines -99 to -116
if e.returncode != 1:
msg = (
"Internal Error: calling {executable} "
"for test {test_id} failed (returncode={returncode}):\n"
"{output}"
)
failure = Catch2Failure(
executable,
0,
msg.format(
executable=executable,
test_id=test_id,
output=e.output,
returncode=e.returncode,
),
)

return [failure], output
Copy link
Collaborator Author

@jnewb1 jnewb1 Sep 8, 2023

Choose a reason for hiding this comment

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

If you get an exit code of >1 (because >1 tests fail), this would force the parser to load the first line of the executable since it's put into the test_file on line 106, which would be in binary and cause an error.

    return [x.rstrip() for x in f.readlines()[index_above : index + 1]]
                                ^^^^^^^^^^^^^
  File "<frozen codecs>", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 24: invalid continuation byte

Copy link
Member

Choose a reason for hiding this comment

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

Ahh definitely, this seems like an oversight.

@@ -151,7 +133,7 @@ def _parse_xml(
test_result = test_case.find("OverallResult")
failures = []
if test_result is not None and test_result.attrib["success"] == "false":
test_checks = test_case.findall("Expression")
test_checks = test_case.findall(".//Expression")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

get recursive test checks

@nicoddemus
Copy link
Member

Looks great, could you also add a new CHANGELOG entry?

Create a new section UNRELEASED at the top, and then add a description of this feature in a user-facing manner.

@nicoddemus
Copy link
Member

Awesome, thanks!

After merging this, I will make a new release.

Thanks again!

@nicoddemus nicoddemus merged commit d24a187 into pytest-dev:master Sep 8, 2023
@nicoddemus
Copy link
Member

2.4.0 is out. 🎉

@jnewb1 jnewb1 deleted the catch2-fix-section branch September 8, 2023 20:56
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.

2 participants