From c334cd4f4cf516ea7bce39af4941b1eb09944949 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 17 Sep 2024 15:54:26 -0700 Subject: [PATCH 1/8] consider catch2's FAIL() --- src/pytest_cpp/catch2.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pytest_cpp/catch2.py b/src/pytest_cpp/catch2.py index 264d015..a61f295 100644 --- a/src/pytest_cpp/catch2.py +++ b/src/pytest_cpp/catch2.py @@ -199,11 +199,12 @@ def _parse_xml( ) ) 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"]) - fail_msg = f"Error: {exception.text}" + fail_msg = f"Error: {exception.text.strip()}" failures.append( ( file_name, From f333b319780f895cb7a8ef0a141a04f8b672416e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 22:55:31 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pytest_cpp/catch2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_cpp/catch2.py b/src/pytest_cpp/catch2.py index a61f295..a90892a 100644 --- a/src/pytest_cpp/catch2.py +++ b/src/pytest_cpp/catch2.py @@ -200,7 +200,7 @@ def _parse_xml( ) test_exception = test_case.findall(".//Exception") test_failure = test_case.findall(".//Failure") - for exception in (test_exception + test_failure): + for exception in test_exception + test_failure: file_name = exception.attrib["filename"] line_num = int(exception.attrib["line"]) From dc4cab1c6fba496f73c6fe3a25834ab1046502a0 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 17 Sep 2024 16:00:45 -0700 Subject: [PATCH 3/8] just nice, not required --- src/pytest_cpp/catch2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_cpp/catch2.py b/src/pytest_cpp/catch2.py index a90892a..ce53ccf 100644 --- a/src/pytest_cpp/catch2.py +++ b/src/pytest_cpp/catch2.py @@ -204,7 +204,7 @@ def _parse_xml( file_name = exception.attrib["filename"] line_num = int(exception.attrib["line"]) - fail_msg = f"Error: {exception.text.strip()}" + fail_msg = f"Error: {exception.text}" failures.append( ( file_name, From bb75d5d650ba9909a3493c6e8532af5d02415a92 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 17 Sep 2024 16:00:48 -0700 Subject: [PATCH 4/8] a test --- tests/catch2_failure.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/catch2_failure.cpp b/tests/catch2_failure.cpp index 46b345d..769e613 100644 --- a/tests/catch2_failure.cpp +++ b/tests/catch2_failure.cpp @@ -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); From 9b583bba03d1a6246822e9ec83913124e1aac948 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 17 Sep 2024 16:01:29 -0700 Subject: [PATCH 5/8] comment --- src/pytest_cpp/catch2.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pytest_cpp/catch2.py b/src/pytest_cpp/catch2.py index ce53ccf..2c237a2 100644 --- a/src/pytest_cpp/catch2.py +++ b/src/pytest_cpp/catch2.py @@ -198,6 +198,7 @@ def _parse_xml( fail_msg, ) ) + # These two tags contain the same attributes and can be treated the same test_exception = test_case.findall(".//Exception") test_failure = test_case.findall(".//Failure") for exception in test_exception + test_failure: From 311395b78ebd9c16af358f95b4df0c42c4f4a710 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Sep 2024 20:32:08 -0300 Subject: [PATCH 6/8] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 636c8f3..df064fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)). From 385c8026ca5a70528abf384999de11b60231879b Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Sep 2024 20:45:52 -0300 Subject: [PATCH 7/8] Update GitHub Actions versions --- .github/workflows/deploy.yml | 8 ++++---- .github/workflows/test.yml | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ccb3d65..a9ee0e9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54ef390..68e2430 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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] @@ -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 From 229f4a018a4c9bb647c9e8b0b4da18087b5eebfa Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Sep 2024 20:47:46 -0300 Subject: [PATCH 8/8] Update upload-artifact action --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 68e2430..5cd3df9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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