From 322193afcdfd3d3ba5a456e5e6f64e3637091736 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 25 Oct 2022 10:46:09 -0400 Subject: cmake --workflow: print usage and exit on unrecognized argument Issue: #24073 --- Source/cmakemain.cxx | 2 ++ Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-result.txt | 1 + Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt | 6 ++++++ Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stdout.txt | 1 + Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake | 1 + 5 files changed, 11 insertions(+) create mode 100644 Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-result.txt create mode 100644 Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt create mode 100644 Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stdout.txt diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 47e34a6..15e3190 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -949,6 +949,8 @@ int do_workflow(int ac, char const* const* av) } if (!(matched && parsed)) { if (!matched) { + presetName.clear(); + listPresets = false; std::cerr << "Unknown argument " << arg << std::endl; } break; diff --git a/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt new file mode 100644 index 0000000..049ff54 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt @@ -0,0 +1,6 @@ +^Unknown argument -DINVALID_OPTION +Usage: cmake --workflow \[options\] +Options: + --preset = Workflow preset to execute\. + --list-presets = List available workflow presets\. + --fresh = Configure a fresh build tree, removing any existing cache file\.$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stdout.txt b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake index b89a11a..c620595 100644 --- a/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake @@ -77,3 +77,4 @@ unset(CMakeUserPresets_FILE) unset(CMakePresets_ASSETS) run_cmake_workflow_presets(ListPresets --list-presets) +run_cmake_workflow_presets(InvalidOption -DINVALID_OPTION) -- cgit v0.12