Skip to content

Migrate catch2 support to version 3 #107

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/pytest_cpp/catch2.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,25 @@ def is_test_suite(
except (subprocess.CalledProcessError, OSError):
return False
else:
return "--list-test-names-only" in output
return "--list-tests" in output

def list_tests(
self,
executable: str,
harness_collect: Sequence[str] = (),
) -> list[str]:
"""
Executes test with "--list-test-names-only" and gets list of tests
Executes test with "--list-tests --verbosity quiet" and gets list of tests
parsing output like this:

1: All test cases reside in other .cpp files (empty)
2: Factorial of 0 is 1 (fail)
2: Factorials of 1 and higher are computed (pass)
"""
# This will return an exit code with the number of tests available
args = make_cmdline(harness_collect, executable, ["--list-test-names-only"])
args = make_cmdline(
harness_collect, executable, ["--list-tests", "--verbosity quiet"]
)
try:
output = subprocess.check_output(
args,
Expand Down Expand Up @@ -145,7 +147,7 @@ def _parse_xml(
) -> Sequence[tuple[str, Sequence[tuple[str, int, str]], bool]]:
root = ElementTree.parse(xml_filename)
result = []
for test_suite in root.findall("Group"):
for test_suite in root.iter("Catch2TestRun"):
for test_case in test_suite.findall("TestCase"):
test_name = test_case.attrib["name"]
test_result = test_case.find("OverallResult")
Expand Down