Skip to content

Commit

Permalink
Consider catch2's FAIL() (#147)
Browse files Browse the repository at this point in the history
`pytest-cpp` was only considering the `REQUIRE` macro.

Co-authored-by: Bruno Oliveira <[email protected]>
  • Loading branch information
sshane and nicoddemus authored Sep 17, 2024
1 parent 0dedca1 commit 8ffb245
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.7

- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v1.5
uses: hynek/build-and-inspect-python-package@v2.9.0

deploy:
needs: package
Expand All @@ -30,10 +30,10 @@ jobs:
contents: write # For tag and release notes.

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.7

- name: Download Package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.8
with:
name: Packages
path: dist
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
gtest_ver: [ "1.11.0" ]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4.1.7
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5.2.0
with:
python-version: "3.8"
- name: Install GoogleTest
Expand All @@ -49,7 +49,7 @@ jobs:
pip install scons
scons -j4 -C tests
- name: Upload compilation results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4.4.0
with:
name: tests
if-no-files-found: error
Expand All @@ -64,9 +64,9 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.7
- name: Build and Check Package
uses: hynek/build-and-inspect-python-package@v1.5
uses: hynek/build-and-inspect-python-package@v2.9.0

test:
needs: [compile, package]
Expand All @@ -78,20 +78,20 @@ jobs:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4.1.7
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5.2.0
with:
python-version: ${{ matrix.python }}

- name: Download compiled tests
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.8
with:
name: tests
path: tests

- name: Download Package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.8
with:
name: Packages
path: dist
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# UNRELEASED

- Catch2: recognize `FAIL()` calls ([#147](https://github.com/pytest-dev/pytest-cpp/pull/147)).

# 2.5.0 (2023-11-01)

- Catch2: add support for catch version 3 ([#115](https://github.com/pytest-dev/pytest-cpp/pull/115)).
Expand Down
4 changes: 3 additions & 1 deletion src/pytest_cpp/catch2.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ def _parse_xml(
fail_msg,
)
)
# These two tags contain the same attributes and can be treated the same
test_exception = test_case.findall(".//Exception")
for exception in test_exception:
test_failure = test_case.findall(".//Failure")
for exception in test_exception + test_failure:
file_name = exception.attrib["filename"]
line_num = int(exception.attrib["line"])

Expand Down
4 changes: 4 additions & 0 deletions tests/catch2_failure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ TEST_CASE( "Factorials are computed", "[factorial]" ) {
REQUIRE( Factorial(10) == 3628800 );
}

TEST_CASE( "Test fail macro" ) {
FAIL("This is a fail");
}

TEST_CASE( "Failed Sections" ) {
SECTION( "failed 1" ) {
REQUIRE(false);
Expand Down

0 comments on commit 8ffb245

Please sign in to comment.