From 8b1d06737454c50ee0f6079a2922065b2d0dca71 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Fri, 24 Oct 2025 05:36:00 -0700 Subject: [PATCH] try adding a test for failure with macos arm precompile (#1238) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 39 ++++++++++++++++++++++- include/CLI/ExtraValidators.hpp | 2 -- include/CLI/impl/Option_inl.hpp | 3 ++ tests/CMakeLists.txt | 1 - tests/FuzzFailTest.cpp | 8 ++--- tests/fuzzFail/fuzz_file_fail9 | 1 + tests/package_config_tests/CMakeLists.txt | 2 +- 7 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 tests/fuzzFail/fuzz_file_fail9 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7f414b4f..028881b2 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 +permissions: + contents: read + env: CTEST_OUTPUT_ON_FAILURE: "1" @@ -126,7 +129,7 @@ jobs: - name: Build run: cmake --build build -j2 - cuda12-build: + cuda13-build: name: CUDA 13 build only runs-on: ubuntu-latest container: nvidia/cuda:13.0.0-devel-ubuntu22.04 @@ -241,6 +244,40 @@ jobs: - name: Run tests run: ctest --output-on-failure -L Packaging working-directory: build + + install-precompiled-macos: + name: install tests precompiled macos + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Configure + run: cmake -S . -B build -DCLI11_INSTALL_PACKAGE_TESTS=ON -DCLI11_ENABLE_EXTRA_VALIDATORS=ON -DCMAKE_INSTALL_PREFIX=/Users/runner/work/install -DCLI11_PRECOMPILED=ON -DCMAKE_CXX_STANDARD=20 + - name: Build + run: cmake --build build -j2 + - name: install + run: cmake --install build + - name: Run tests + run: ctest --output-on-failure -L Packaging + working-directory: build + + install-precompiled-macos-no-validators: + name: install tests precompiled macos no validators + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Configure + run: cmake -S . -B build -DCLI11_INSTALL_PACKAGE_TESTS=ON -DCLI11_ENABLE_EXTRA_VALIDATORS=OFF -DCMAKE_INSTALL_PREFIX=/Users/runner/work/install -DCLI11_PRECOMPILED=ON + - name: Build + run: cmake --build build -j2 + - name: install + run: cmake --install build + - name: Run tests + run: ctest --output-on-failure -L Packaging + working-directory: build install-single_file: name: install tests single file diff --git a/include/CLI/ExtraValidators.hpp b/include/CLI/ExtraValidators.hpp index 4d34d212..e861eb41 100644 --- a/include/CLI/ExtraValidators.hpp +++ b/include/CLI/ExtraValidators.hpp @@ -4,8 +4,6 @@ // // SPDX-License-Identifier: BSD-3-Clause -#define CLI11_ENABLE_EXTRA_VALIDATORS 1 - #pragma once #if (defined(CLI11_ENABLE_EXTRA_VALIDATORS) && CLI11_ENABLE_EXTRA_VALIDATORS == 1) || \ (!defined(CLI11_DISABLE_EXTRA_VALIDATORS) || CLI11_DISABLE_EXTRA_VALIDATORS == 0) diff --git a/include/CLI/impl/Option_inl.hpp b/include/CLI/impl/Option_inl.hpp index 468d2c7e..0cab7247 100644 --- a/include/CLI/impl/Option_inl.hpp +++ b/include/CLI/impl/Option_inl.hpp @@ -325,6 +325,9 @@ CLI11_INLINE void Option::run_callback() { current_option_state_ = option_state::callback_run; if(callback_) { const results_t &send_results = proc_results_.empty() ? results_ : proc_results_; + if(send_results.empty()) { + return; + } bool local_result = callback_(send_results); if(used_default_str) { // we only clear the results if the callback was actually used diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 43105dc3..23cde591 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -362,7 +362,6 @@ if(CLI11_INSTALL_PACKAGE_TESTS) add_test( package-config-tests ${CMAKE_CTEST_COMMAND} - -C --build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/package_config_tests" "${CMAKE_CURRENT_BINARY_DIR}/package_config_tests" diff --git a/tests/FuzzFailTest.cpp b/tests/FuzzFailTest.cpp index 5ce616eb..b1f7bad4 100644 --- a/tests/FuzzFailTest.cpp +++ b/tests/FuzzFailTest.cpp @@ -55,7 +55,7 @@ TEST_CASE("file_fail") { CLI::FuzzApp fuzzdata; auto app = fuzzdata.generateApp(); - int index = GENERATE(range(1, 9)); + int index = GENERATE(range(1, 10)); auto parseData = loadFailureFile("fuzz_file_fail", index); std::stringstream out(parseData); try { @@ -149,7 +149,7 @@ TEST_CASE("app_file_roundtrip") { result = fuzzdata2.compare(fuzzdata); } */ - INFO("Failure in test case " << index) + INFO("Failure in test case " << index); CHECK(result); } @@ -352,7 +352,7 @@ TEST_CASE("app_roundtrip_custom") { std::size_t pstring_start{0}; pstring_start = fuzzdata.add_custom_options(app.get(), parseData); INFO("Failure in test case " << index << " file length=" << parseData.size() << " pstring start at " - << pstring_start) + << pstring_start); if(pstring_start > 0) { app->parse(parseData.substr(pstring_start)); CHECK_NOTHROW(app->help("", CLI::AppFormatMode::All)); @@ -392,7 +392,7 @@ TEST_CASE("app_roundtrip_parse_normal_fail") { CHECK(true); return; } - INFO("Failure in test case " << index) + INFO("Failure in test case " << index); try { if(pstring_start > 0) { app->parse(parseData.substr(pstring_start)); diff --git a/tests/fuzzFail/fuzz_file_fail9 b/tests/fuzzFail/fuzz_file_fail9 new file mode 100644 index 00000000..c0b136ff --- /dev/null +++ b/tests/fuzzFail/fuzz_file_fail9 @@ -0,0 +1 @@ +vdtr9=[ \ No newline at end of file diff --git a/tests/package_config_tests/CMakeLists.txt b/tests/package_config_tests/CMakeLists.txt index 62255724..ee99f947 100644 --- a/tests/package_config_tests/CMakeLists.txt +++ b/tests/package_config_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14...4.0) +cmake_minimum_required(VERSION 3.14...4.1) project(CLI11-package-config-test)