diff --git a/test/testprocessexecutor.cpp b/test/testprocessexecutor.cpp index a59ee2c8ca77..360407a08712 100644 --- a/test/testprocessexecutor.cpp +++ b/test/testprocessexecutor.cpp @@ -56,6 +56,7 @@ class TestProcessExecutorBase : public TestFixture { SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE; const char* plistOutput = nullptr; std::vector filesList; + bool clangTidy = false; bool executeCommandCalled = false; std::string exe; std::vector args; @@ -68,17 +69,18 @@ class TestProcessExecutorBase : public TestFixture { void check(unsigned int jobs, int files, int result, const std::string &data, const CheckOptions& opt = make_default_obj{}) { errout.str(""); output.str(""); - settings.project.fileSettings.clear(); + + Settings s = settings; std::map filemap; if (opt.filesList.empty()) { for (int i = 1; i <= files; ++i) { - std::string s = fprefix() + "_" + std::to_string(i) + ".cpp"; - filemap[s] = data.size(); + std::string f_s = fprefix() + "_" + std::to_string(i) + ".cpp"; + filemap[f_s] = data.size(); if (useFS) { ImportProject::FileSettings fs; - fs.filename = std::move(s); - settings.project.fileSettings.emplace_back(std::move(fs)); + fs.filename = std::move(f_s); + s.project.fileSettings.emplace_back(std::move(fs)); } } } @@ -89,12 +91,11 @@ class TestProcessExecutorBase : public TestFixture { if (useFS) { ImportProject::FileSettings fs; fs.filename = f; - settings.project.fileSettings.emplace_back(std::move(fs)); + s.project.fileSettings.emplace_back(std::move(fs)); } } } - Settings s = settings; s.jobs = jobs; s.showtime = opt.showtime; s.quiet = opt.quiet; @@ -285,9 +286,6 @@ class TestProcessExecutorBase : public TestFixture { if (!useFS) return; - const Settings settingsOld = settings; - settings.clangTidy = true; - #ifdef _WIN32 const char exe[] = "clang-tidy.exe"; #else @@ -303,12 +301,12 @@ class TestProcessExecutorBase : public TestFixture { " return 0;\n" "}", dinit(CheckOptions, - $.quiet = false/*, + $.quiet = false, + $.clangTidy = true/*, $.executeCommandCalled = true, $.exe = exe, $.args = {"-quiet", "-checks=*,-clang-analyzer-*,-llvm*", file, "--"}*/)); ASSERT_EQUALS("Checking " + file + " ...\n", output.str()); - settings = settingsOld; } // TODO: provide data which actually shows values above 0 diff --git a/test/testsingleexecutor.cpp b/test/testsingleexecutor.cpp index 75433393ba85..01adac877979 100644 --- a/test/testsingleexecutor.cpp +++ b/test/testsingleexecutor.cpp @@ -68,6 +68,7 @@ class TestSingleExecutorBase : public TestFixture { SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE; const char* plistOutput = nullptr; std::vector filesList; + bool clangTidy = false; bool executeCommandCalled = false; std::string exe; std::vector args; @@ -76,17 +77,18 @@ class TestSingleExecutorBase : public TestFixture { void check(int files, int result, const std::string &data, const CheckOptions& opt = make_default_obj{}) { errout.str(""); output.str(""); - settings.project.fileSettings.clear(); + + Settings s = settings; std::map filemap; if (opt.filesList.empty()) { for (int i = 1; i <= files; ++i) { - std::string s = fprefix() + "_" + zpad3(i) + ".cpp"; - filemap[s] = data.size(); + std::string f_s = fprefix() + "_" + zpad3(i) + ".cpp"; + filemap[f_s] = data.size(); if (useFS) { ImportProject::FileSettings fs; - fs.filename = std::move(s); - settings.project.fileSettings.emplace_back(std::move(fs)); + fs.filename = std::move(f_s); + s.project.fileSettings.emplace_back(std::move(fs)); } } } @@ -97,16 +99,16 @@ class TestSingleExecutorBase : public TestFixture { if (useFS) { ImportProject::FileSettings fs; fs.filename = f; - settings.project.fileSettings.emplace_back(std::move(fs)); + s.project.fileSettings.emplace_back(std::move(fs)); } } } - Settings s = settings; s.showtime = opt.showtime; s.quiet = opt.quiet; if (opt.plistOutput) s.plistOutput = opt.plistOutput; + s.clangTidy = opt.clangTidy; bool executeCommandCalled = false; std::string exe; @@ -274,9 +276,6 @@ class TestSingleExecutorBase : public TestFixture { if (!useFS) return; - const Settings settingsOld = settings; - settings.clangTidy = true; - #ifdef _WIN32 const char exe[] = "clang-tidy.exe"; #else @@ -291,11 +290,11 @@ class TestSingleExecutorBase : public TestFixture { "}", dinit(CheckOptions, $.quiet = false, + $.clangTidy = true, $.executeCommandCalled = true, $.exe = exe, $.args = {"-quiet", "-checks=*,-clang-analyzer-*,-llvm*", file, "--"})); ASSERT_EQUALS("Checking " + file + " ...\n", output.str()); - settings = settingsOld; } // TODO: provide data which actually shows values above 0 diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index 6e27e694a663..2d2dd3b1f5ef 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -56,6 +56,7 @@ class TestThreadExecutorBase : public TestFixture { SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE; const char* plistOutput = nullptr; std::vector filesList; + bool clangTidy = false; bool executeCommandCalled = false; std::string exe; std::vector args; @@ -68,17 +69,18 @@ class TestThreadExecutorBase : public TestFixture { void check(unsigned int jobs, int files, int result, const std::string &data, const CheckOptions& opt = make_default_obj{}) { errout.str(""); output.str(""); - settings.project.fileSettings.clear(); + + Settings s = settings; std::map filemap; if (opt.filesList.empty()) { for (int i = 1; i <= files; ++i) { - std::string s = fprefix() + "_" + std::to_string(i) + ".cpp"; - filemap[s] = data.size(); + std::string f_s = fprefix() + "_" + std::to_string(i) + ".cpp"; + filemap[f_s] = data.size(); if (useFS) { ImportProject::FileSettings fs; - fs.filename = std::move(s); - settings.project.fileSettings.emplace_back(std::move(fs)); + fs.filename = std::move(f_s); + s.project.fileSettings.emplace_back(std::move(fs)); } } } @@ -89,17 +91,17 @@ class TestThreadExecutorBase : public TestFixture { if (useFS) { ImportProject::FileSettings fs; fs.filename = f; - settings.project.fileSettings.emplace_back(std::move(fs)); + s.project.fileSettings.emplace_back(std::move(fs)); } } } - Settings s = settings; s.jobs = jobs; s.showtime = opt.showtime; s.quiet = opt.quiet; if (opt.plistOutput) s.plistOutput = opt.plistOutput; + s.clangTidy = opt.clangTidy; bool executeCommandCalled = false; std::string exe; @@ -283,9 +285,6 @@ class TestThreadExecutorBase : public TestFixture { if (!useFS) return; - const Settings settingsOld = settings; - settings.clangTidy = true; - #ifdef _WIN32 const char exe[] = "clang-tidy.exe"; #else @@ -300,11 +299,11 @@ class TestThreadExecutorBase : public TestFixture { "}", dinit(CheckOptions, $.quiet = false, + $.clangTidy = true, $.executeCommandCalled = true, $.exe = exe, $.args = {"-quiet", "-checks=*,-clang-analyzer-*,-llvm*", file, "--"})); ASSERT_EQUALS("Checking " + file + " ...\n", output.str()); - settings = settingsOld; } // TODO: provide data which actually shows values above 0