From 7a10718ab5696581812129cc94745036409b63f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 20 Jul 2024 21:34:42 +0200 Subject: [PATCH] Fix #12828 (cmdline: suggestion to use --checkers-report even though it is used) --- cli/cppcheckexecutor.cpp | 4 +++- test/cli/other_test.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 31122583e24..4904bee4570 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -342,7 +342,9 @@ void StdLogger::writeCheckersReport() what = std::to_string(activeCheckers) + "/" + std::to_string(totalCheckers); else what = "There was critical errors"; - msg.setmsg("Active checkers: " + what + " (use --checkers-report= to see details)"); + if (mSettings.checkersReportFilename.empty()) + what += " (use --checkers-report= to see details)"; + msg.setmsg("Active checkers: " + what); reportErr(msg); } diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 1206c45c57d..c87a7c4a859 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -1752,3 +1752,14 @@ def test_lib_lookup_multi(tmpdir): "looking for library '{}/cfg/gnu.cfg'".format(exepath), 'Checking {} ...'.format(test_file) ] + + +def test_checkers_report(tmpdir): + test_file = os.path.join(tmpdir, 'test.c') + with open(test_file, 'wt') as f: + f.write('x=1;') + checkers_report = os.path.join(tmpdir, 'r.txt') + exitcode, stdout, stderr, exe = cppcheck_ex(['--enable=all', '--checkers-report=' + checkers_report, test_file], remove_checkers_report=False) + assert exitcode == 0, stdout + assert 'Active checkers:' in stderr + assert '--checkers-report' not in stderr