From 5c2ed07fb6090fcbc9b31207db860c49d7f8bc8f Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 3 Sep 2025 09:50:17 +0200 Subject: [PATCH] fixed #14108 - TestCppcheck: use unique names for generated files --- test/testcppcheck.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 8c53bf2facc..c4b818b79b9 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -131,7 +131,7 @@ class TestCppcheck : public TestFixture { #endif } - CppCheck::ExecuteCmdFn getExecuteCommand(int& called) const + CppCheck::ExecuteCmdFn getExecuteCommand(const std::string& fname, int& called) const { // cppcheck-suppress passedByValue - used as callback so we need to preserve the signature // NOLINTNEXTLINE(performance-unnecessary-value-param) - used as callback so we need to preserve the signature @@ -142,7 +142,7 @@ class TestCppcheck : public TestFixture { ASSERT_EQUALS(4, args.size()); ASSERT_EQUALS("-quiet", args[0]); ASSERT_EQUALS("-checks=*,-clang-analyzer-*,-llvm*", args[1]); - ASSERT_EQUALS("test.cpp", args[2]); + ASSERT_EQUALS(fname, args[2]); ASSERT_EQUALS("--", args[3]); ASSERT_EQUALS("2>&1", redirect); return EXIT_SUCCESS; @@ -166,10 +166,10 @@ class TestCppcheck : public TestFixture { }; } - void checkWithFileInternal(bool tools, bool nocmd = false) const + void checkWithFileInternal(const std::string& fname, bool tools, bool nocmd = false) const { REDIRECT; - ScopedFile file("test.cpp", + ScopedFile file(fname, "int main()\n" "{\n" " int i = *((int*)0);\n" @@ -193,7 +193,7 @@ class TestCppcheck : public TestFixture { ErrorLogger2 errorLogger; CppCheck::ExecuteCmdFn f; if (tools && !nocmd) { - f = getExecuteCommand(called); + f = getExecuteCommand(fname, called); } CppCheck cppcheck(s, supprs, errorLogger, false, f); ASSERT_EQUALS(1, cppcheck.check(FileWithDetails(file.path(), Path::identify(file.path(), false), 0))); @@ -240,21 +240,21 @@ class TestCppcheck : public TestFixture { } void checkWithFile() const { - checkWithFileInternal(false); + checkWithFileInternal("file.cpp", false); } void checkWithFileWithTools() const { - checkWithFileInternal(true); + checkWithFileInternal("file_tools.cpp", true); } void checkWithFileWithToolsNoCommand() const { - checkWithFileInternal(true, true); + checkWithFileInternal("file_tools_nocmd.cpp", true, true); } - void checkWithFSInternal(bool tools, bool nocmd = false) const + void checkWithFSInternal(const std::string& fname, bool tools, bool nocmd = false) const { REDIRECT; - ScopedFile file("test.cpp", + ScopedFile file(fname, "int main()\n" "{\n" " int i = *((int*)0);\n" @@ -278,7 +278,7 @@ class TestCppcheck : public TestFixture { ErrorLogger2 errorLogger; CppCheck::ExecuteCmdFn f; if (tools && !nocmd) { - f = getExecuteCommand(called); + f = getExecuteCommand(fname, called); } CppCheck cppcheck(s, supprs, errorLogger, false, f); FileSettings fs{file.path(), Path::identify(file.path(), false), 0}; @@ -325,20 +325,20 @@ class TestCppcheck : public TestFixture { } void checkWithFS() const { - checkWithFSInternal(false); + checkWithFSInternal("fs.cpp", false); } void checkWithFSWithTools() const { - checkWithFSInternal(true); + checkWithFSInternal("fs_tools.cpp", true); } void checkWithFSWithToolsNoCommand() const { - checkWithFSInternal(true, true); + checkWithFSInternal("fs_tools_nocmd.cpp", true, true); } void suppress_error_library() const { - ScopedFile file("test.cpp", + ScopedFile file("suppr_err_lib.cpp", "int main()\n" "{\n" " int i = *((int*)0);\n"