Skip to content

Commit 301b19d

Browse files
authored
fixed #14108 - TestCppcheck: use unique names for generated files (#7792)
1 parent 4bb3d95 commit 301b19d

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/testcppcheck.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class TestCppcheck : public TestFixture {
131131
#endif
132132
}
133133

134-
CppCheck::ExecuteCmdFn getExecuteCommand(int& called) const
134+
CppCheck::ExecuteCmdFn getExecuteCommand(const std::string& fname, int& called) const
135135
{
136136
// cppcheck-suppress passedByValue - used as callback so we need to preserve the signature
137137
// NOLINTNEXTLINE(performance-unnecessary-value-param) - used as callback so we need to preserve the signature
@@ -142,7 +142,7 @@ class TestCppcheck : public TestFixture {
142142
ASSERT_EQUALS(4, args.size());
143143
ASSERT_EQUALS("-quiet", args[0]);
144144
ASSERT_EQUALS("-checks=*,-clang-analyzer-*,-llvm*", args[1]);
145-
ASSERT_EQUALS("test.cpp", args[2]);
145+
ASSERT_EQUALS(fname, args[2]);
146146
ASSERT_EQUALS("--", args[3]);
147147
ASSERT_EQUALS("2>&1", redirect);
148148
return EXIT_SUCCESS;
@@ -166,10 +166,10 @@ class TestCppcheck : public TestFixture {
166166
};
167167
}
168168

169-
void checkWithFileInternal(bool tools, bool nocmd = false) const
169+
void checkWithFileInternal(const std::string& fname, bool tools, bool nocmd = false) const
170170
{
171171
REDIRECT;
172-
ScopedFile file("test.cpp",
172+
ScopedFile file(fname,
173173
"int main()\n"
174174
"{\n"
175175
" int i = *((int*)0);\n"
@@ -193,7 +193,7 @@ class TestCppcheck : public TestFixture {
193193
ErrorLogger2 errorLogger;
194194
CppCheck::ExecuteCmdFn f;
195195
if (tools && !nocmd) {
196-
f = getExecuteCommand(called);
196+
f = getExecuteCommand(fname, called);
197197
}
198198
CppCheck cppcheck(s, supprs, errorLogger, false, f);
199199
ASSERT_EQUALS(1, cppcheck.check(FileWithDetails(file.path(), Path::identify(file.path(), false), 0)));
@@ -240,21 +240,21 @@ class TestCppcheck : public TestFixture {
240240
}
241241

242242
void checkWithFile() const {
243-
checkWithFileInternal(false);
243+
checkWithFileInternal("file.cpp", false);
244244
}
245245

246246
void checkWithFileWithTools() const {
247-
checkWithFileInternal(true);
247+
checkWithFileInternal("file_tools.cpp", true);
248248
}
249249

250250
void checkWithFileWithToolsNoCommand() const {
251-
checkWithFileInternal(true, true);
251+
checkWithFileInternal("file_tools_nocmd.cpp", true, true);
252252
}
253253

254-
void checkWithFSInternal(bool tools, bool nocmd = false) const
254+
void checkWithFSInternal(const std::string& fname, bool tools, bool nocmd = false) const
255255
{
256256
REDIRECT;
257-
ScopedFile file("test.cpp",
257+
ScopedFile file(fname,
258258
"int main()\n"
259259
"{\n"
260260
" int i = *((int*)0);\n"
@@ -278,7 +278,7 @@ class TestCppcheck : public TestFixture {
278278
ErrorLogger2 errorLogger;
279279
CppCheck::ExecuteCmdFn f;
280280
if (tools && !nocmd) {
281-
f = getExecuteCommand(called);
281+
f = getExecuteCommand(fname, called);
282282
}
283283
CppCheck cppcheck(s, supprs, errorLogger, false, f);
284284
FileSettings fs{file.path(), Path::identify(file.path(), false), 0};
@@ -325,20 +325,20 @@ class TestCppcheck : public TestFixture {
325325
}
326326

327327
void checkWithFS() const {
328-
checkWithFSInternal(false);
328+
checkWithFSInternal("fs.cpp", false);
329329
}
330330

331331
void checkWithFSWithTools() const {
332-
checkWithFSInternal(true);
332+
checkWithFSInternal("fs_tools.cpp", true);
333333
}
334334

335335
void checkWithFSWithToolsNoCommand() const {
336-
checkWithFSInternal(true, true);
336+
checkWithFSInternal("fs_tools_nocmd.cpp", true, true);
337337
}
338338

339339
void suppress_error_library() const
340340
{
341-
ScopedFile file("test.cpp",
341+
ScopedFile file("suppr_err_lib.cpp",
342342
"int main()\n"
343343
"{\n"
344344
" int i = *((int*)0);\n"

0 commit comments

Comments
 (0)