From 386cb8dcf7a88edc333947674e7da6703ccbdb77 Mon Sep 17 00:00:00 2001 From: 94xhn <87560781+94xhn@users.noreply.github.com> Date: Wed, 15 Jul 2026 01:26:51 +0800 Subject: [PATCH] Make --tree-suite-result select tree output The long tree-output option set only_test_suite_result while its -t alias set tree_test_suite_result. As a result, the documented long form printed the one-line suite summary instead of the nested result tree. Map both aliases to the same field and add a parser regression covering the selected and unselected output modes. Constraint: Long and short aliases must produce identical CommandLineOptions state. Rejected: Change the output dispatcher | the dispatcher already distinguishes the two valid modes correctly. Confidence: high Scope-risk: narrow Directive: Keep each command-line alias pair mapped to the same option field. Tested: baseline/fixed GCC 13 C++20 harness; command-line-arguments suite; 92-step CMake/Ninja build; full cest-runner exit 0; long/short nested-tree output match; git diff --check Not-tested: Quom single-header regeneration in this environment because Quom is not installed; CI installs it --- src/arg-parser.hpp | 2 +- test/framework/command-line-arguments.test.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/arg-parser.hpp b/src/arg-parser.hpp index c4cc541..485d324 100644 --- a/src/arg-parser.hpp +++ b/src/arg-parser.hpp @@ -18,7 +18,7 @@ namespace cest {"-j", [&]() { options.json_output = true; }}, {"--only-suite-result", [&]() { options.only_test_suite_result = true; }}, {"-o", [&]() { options.only_test_suite_result = true; }}, - {"--tree-suite-result", [&]() { options.only_test_suite_result = true; }}, + {"--tree-suite-result", [&]() { options.tree_test_suite_result = true; }}, {"-t", [&]() { options.tree_test_suite_result = true; }}, {"--print-test-list", [&]() { options.print_test_list = true; }}, {"-l", [&]() { options.print_test_list = true; }} diff --git a/test/framework/command-line-arguments.test.cpp b/test/framework/command-line-arguments.test.cpp index 3795788..90310b1 100644 --- a/test/framework/command-line-arguments.test.cpp +++ b/test/framework/command-line-arguments.test.cpp @@ -1,4 +1,5 @@ #include +#include describe("Cest command line options", []() { it("will use default behaviour if empty", []() { @@ -104,6 +105,20 @@ describe("Cest command line options", []() { expect(options.json_output).toBe(true); }); + it("will use tree suite output for the long and short options", []() { + int argc = 2; + std::array long_argv = { "/bin/cest", "--tree-suite-result" }; + std::array short_argv = { "/bin/cest", "-t" }; + + auto long_options = cest::parseArgs(argc, long_argv.data()); + auto short_options = cest::parseArgs(argc, short_argv.data()); + + expect(long_options.tree_test_suite_result).toBe(true); + expect(long_options.only_test_suite_result).toBe(false); + expect(short_options.tree_test_suite_result).toBe(true); + expect(short_options.only_test_suite_result).toBe(false); + }); + it("will set filter when --grep is present", []() { int argc = 3; const char *argv[] = { "/bin/cest", "--grep", "booleans" };