diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2482cdb2e..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 @@ -57,6 +60,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 @@ -138,7 +165,7 @@ jobs: - name: Build run: meson compile -C build-meson - + install: name: install tests runs-on: ubuntu-latest @@ -155,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 @@ -172,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 @@ -341,7 +368,7 @@ jobs: with: cmake-version: "3.27" if: success() || failure() - + - name: Check CMake 3.28 (full) uses: ./.github/actions/quick_cmake with: 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/OptionalTest.cpp b/tests/OptionalTest.cpp index 6906fc9d4..986272d01 100644 --- a/tests/OptionalTest.cpp +++ b/tests/OptionalTest.cpp @@ -53,6 +53,8 @@ #endif // [CLI11:verbatim] +TEST_CASE("OptionalNoEmpty") { CHECK(1 == 1); } + #if CLI11_STD_OPTIONAL #ifdef _MSC_VER diff --git a/tests/catch.hpp b/tests/catch.hpp index 1523a47df..4dd233603 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::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); } @@ -26,6 +30,7 @@ inline auto Contains(const std::string &x) { return Catch::Matchers::ContainsSub #include 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