From e596b514cdb6f2d0190057d2783afccffe177a36 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 12 Jan 2024 12:25:14 -0500 Subject: [PATCH 1/6] tests: fix catch2 3 support Signed-off-by: Henry Schreiner --- tests/OptionTypeTest.cpp | 5 +++-- tests/catch.hpp | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/OptionTypeTest.cpp b/tests/OptionTypeTest.cpp index 1830c2c96..5068a8c65 100644 --- a/tests/OptionTypeTest.cpp +++ b/tests/OptionTypeTest.cpp @@ -6,6 +6,8 @@ #include "app_helper.hpp" +#include "catch.hpp" + #include #include #include @@ -243,7 +245,6 @@ static const std::map testValuesDouble{ }; TEST_CASE_METHOD(TApp, "floatingConversions", "[optiontype]") { - auto test_data = GENERATE(from_range(testValuesDouble)); double val{0}; @@ -256,7 +257,7 @@ TEST_CASE_METHOD(TApp, "floatingConversions", "[optiontype]") { CHECK(std::isnan(val)); } else { - CHECK_THAT(val, Catch::WithinRel(test_data.second, 1e-11)); + CHECK_THAT(val, WithinRel(test_data.second, 1e-11)); } } diff --git a/tests/catch.hpp b/tests/catch.hpp index 1523a47df..72450e928 100644 --- a/tests/catch.hpp +++ b/tests/catch.hpp @@ -14,10 +14,14 @@ #include #include #include +#include #include +#include -using Catch::Approx; // NOLINT(google-global-names-in-headers) -using Catch::Matchers::Equals; // NOLINT(google-global-names-in-headers) +using Catch::Approx; // NOLINT(google-global-names-in-headers) +using Catch::Matchers::Equals; // NOLINT(google-global-names-in-headers) +using Catch::Matchers::WithinRel; // NOLINT(google-global-names-in-headers) +using Catch::Generators::from_range; // NOLINT(google-global-names-in-headers) inline auto Contains(const std::string &x) { return Catch::Matchers::ContainsSubstring(x); } @@ -25,7 +29,8 @@ inline auto Contains(const std::string &x) { return Catch::Matchers::ContainsSub #include -using Catch::Equals; // NOLINT(google-global-names-in-headers) -using Catch::Matchers::Contains; // NOLINT(google-global-names-in-headers) +using Catch::Equals; // NOLINT(google-global-names-in-headers) +using Catch::Matchers::Contains; // NOLINT(google-global-names-in-headers) +using Catch::WithinRel; // NOLINT(google-global-names-in-headers) #endif From a107b8e8c95bc30df183f027846cd4487cd9c52d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 17:42:34 +0000 Subject: [PATCH 2/6] style: pre-commit.ci fixes --- tests/catch.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/catch.hpp b/tests/catch.hpp index 72450e928..4dd233603 100644 --- a/tests/catch.hpp +++ b/tests/catch.hpp @@ -15,13 +15,13 @@ #include #include #include -#include #include +#include -using Catch::Approx; // NOLINT(google-global-names-in-headers) -using Catch::Matchers::Equals; // NOLINT(google-global-names-in-headers) -using Catch::Matchers::WithinRel; // NOLINT(google-global-names-in-headers) -using Catch::Generators::from_range; // NOLINT(google-global-names-in-headers) +using Catch::Approx; // NOLINT(google-global-names-in-headers) +using Catch::Generators::from_range; // NOLINT(google-global-names-in-headers) +using Catch::Matchers::Equals; // NOLINT(google-global-names-in-headers) +using Catch::Matchers::WithinRel; // NOLINT(google-global-names-in-headers) inline auto Contains(const std::string &x) { return Catch::Matchers::ContainsSubstring(x); } @@ -29,8 +29,8 @@ inline auto Contains(const std::string &x) { return Catch::Matchers::ContainsSub #include -using Catch::Equals; // NOLINT(google-global-names-in-headers) -using Catch::Matchers::Contains; // NOLINT(google-global-names-in-headers) -using Catch::WithinRel; // NOLINT(google-global-names-in-headers) +using Catch::Equals; // NOLINT(google-global-names-in-headers) +using Catch::WithinRel; // NOLINT(google-global-names-in-headers) +using Catch::Matchers::Contains; // NOLINT(google-global-names-in-headers) #endif From 87ff01cf6cc31dc6ca949100261a9b0f50a223d6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 12 Jan 2024 14:56:53 -0500 Subject: [PATCH 3/6] ci: check catch2 3 Signed-off-by: Henry Schreiner --- .github/workflows/tests.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2482cdb2e..f1f283159 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,6 +57,30 @@ jobs: files: build/coverage.info functionalities: fixes + catch2-3: + name: Catch 2 3.x + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Get Catch 2 + run: brew install catch2 + + - name: Configure + run: | + cmake -S . -B build \ + -DCMAKE_CXX_STANDARD=14 \ + -DCLI11_SINGLE_FILE_TESTS=OFF \ + -DCLI11_BUILD_EXAMPLES=OFF \ + -DCLI11_PRECOMPILED=ON + + - name: Build + run: cmake --build build -j4 + + - name: Test + run: cmake --build build --target test + + clang-tidy: name: Clang-Tidy runs-on: ubuntu-latest From 2756a524001c88e88343ee178bcfb26265bdd442 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 12 Jan 2024 16:28:47 -0500 Subject: [PATCH 4/6] ci: print out errors on failures Signed-off-by: Henry Schreiner --- .github/workflows/tests.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f1f283159..460d2ebd3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,6 +10,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + CTEST_OUTPUT_ON_FAILURE: "1" + jobs: coverage: name: Coverage @@ -65,7 +68,7 @@ jobs: - name: Get Catch 2 run: brew install catch2 - + - name: Configure run: | cmake -S . -B build \ @@ -162,7 +165,7 @@ jobs: - name: Build run: meson compile -C build-meson - + install: name: install tests runs-on: ubuntu-latest @@ -179,7 +182,7 @@ jobs: - name: Run tests run: ctest --output-on-failure -L Packaging working-directory: build - + install-precompiled: name: install tests precompiled runs-on: ubuntu-latest @@ -196,7 +199,7 @@ jobs: - name: Run tests run: ctest --output-on-failure -L Packaging working-directory: build - + install-single_file: name: install tests single file runs-on: ubuntu-latest @@ -365,7 +368,7 @@ jobs: with: cmake-version: "3.27" if: success() || failure() - + - name: Check CMake 3.28 (full) uses: ./.github/actions/quick_cmake with: From ee2bb6d434228b427cbf4c16425ee0142b2add7a Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 12 Jan 2024 16:58:06 -0500 Subject: [PATCH 5/6] ci: allow optional file to be 'empty' Signed-off-by: Henry Schreiner --- tests/OptionalTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/OptionalTest.cpp b/tests/OptionalTest.cpp index 6906fc9d4..76a93e35e 100644 --- a/tests/OptionalTest.cpp +++ b/tests/OptionalTest.cpp @@ -53,6 +53,10 @@ #endif // [CLI11:verbatim] +TEST_CASE("OptionalNoEmpty") { + CHECK(1 == 1); +} + #if CLI11_STD_OPTIONAL #ifdef _MSC_VER From ee53a1dbfd41f80d0801e886b88ba09c1984d50c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 21:58:34 +0000 Subject: [PATCH 6/6] style: pre-commit.ci fixes --- tests/OptionalTest.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/OptionalTest.cpp b/tests/OptionalTest.cpp index 76a93e35e..986272d01 100644 --- a/tests/OptionalTest.cpp +++ b/tests/OptionalTest.cpp @@ -53,9 +53,7 @@ #endif // [CLI11:verbatim] -TEST_CASE("OptionalNoEmpty") { - CHECK(1 == 1); -} +TEST_CASE("OptionalNoEmpty") { CHECK(1 == 1); } #if CLI11_STD_OPTIONAL