TestSingleExecutor: test clang-tidy invocation (#5294)
This commit is contained in:
parent
dcdf67a694
commit
988edd24c2
|
@ -280,9 +280,11 @@ unsigned int ProcessExecutor::check()
|
|||
|
||||
if (iFileSettings != mSettings.project.fileSettings.end()) {
|
||||
resultOfCheck = fileChecker.check(*iFileSettings);
|
||||
// TODO: call analyseClangTidy()
|
||||
} else {
|
||||
// Read file from a file
|
||||
resultOfCheck = fileChecker.check(iFile->first);
|
||||
// TODO: call analyseClangTidy()?
|
||||
}
|
||||
|
||||
pipewriter.writeEnd(std::to_string(resultOfCheck));
|
||||
|
|
|
@ -61,7 +61,7 @@ unsigned int SingleExecutor::check()
|
|||
processedsize += i->second;
|
||||
if (!mSettings.quiet)
|
||||
reportStatus(c + 1, mFiles.size(), processedsize, totalfilesize);
|
||||
// TODO: call analyseClangTidy()
|
||||
// TODO: call analyseClangTidy()?
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ unsigned int SingleExecutor::check()
|
|||
processedsize += i->second;
|
||||
if (!mSettings.quiet)
|
||||
reportStatus(c + 1, mFiles.size(), processedsize, totalfilesize);
|
||||
// TODO: call analyseClangTidy()
|
||||
// TODO: call analyseClangTidy()?
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ public:
|
|||
} else {
|
||||
// Read file from a file
|
||||
result = fileChecker.check(*file);
|
||||
// TODO: call analyseClangTidy()?
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -229,6 +229,9 @@ private:
|
|||
output.str());*/
|
||||
settings = settingsOld;
|
||||
}
|
||||
|
||||
// TODO: test clang-tidy
|
||||
// TODO: test whole program analysis
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestProcessExecutor)
|
||||
|
|
|
@ -67,6 +67,9 @@ private:
|
|||
SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE;
|
||||
const char* plistOutput = nullptr;
|
||||
std::vector<std::string> filesList;
|
||||
bool executeCommandCalled = false;
|
||||
std::string exe;
|
||||
std::vector<std::string> args;
|
||||
};
|
||||
|
||||
void check(int files, int result, const std::string &data, const CheckOptions &opt = {}) {
|
||||
|
@ -101,9 +104,16 @@ private:
|
|||
settings.showtime = opt.showtime;
|
||||
if (opt.plistOutput)
|
||||
settings.plistOutput = opt.plistOutput;
|
||||
|
||||
bool executeCommandCalled = false;
|
||||
std::string exe;
|
||||
std::vector<std::string> args;
|
||||
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||
CppCheck cppcheck(*this, true, [](std::string,std::vector<std::string>,std::string,std::string&){
|
||||
return false;
|
||||
CppCheck cppcheck(*this, true, [&executeCommandCalled, &exe, &args](std::string e,std::vector<std::string> a,std::string,std::string&){
|
||||
executeCommandCalled = true;
|
||||
exe = std::move(e);
|
||||
args = std::move(a);
|
||||
return true;
|
||||
});
|
||||
cppcheck.settings() = settings;
|
||||
|
||||
|
@ -119,6 +129,13 @@ private:
|
|||
// TODO: test with settings.project.fileSettings;
|
||||
SingleExecutor executor(cppcheck, filemap, settings, settings.nomsg, *this);
|
||||
ASSERT_EQUALS(result, executor.check());
|
||||
ASSERT_EQUALS(opt.executeCommandCalled, executeCommandCalled);
|
||||
ASSERT_EQUALS(opt.exe, exe);
|
||||
ASSERT_EQUALS(opt.args.size(), args.size());
|
||||
for (int i = 0; i < args.size(); ++i)
|
||||
{
|
||||
ASSERT_EQUALS(opt.args[i], args[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void run() override {
|
||||
|
@ -131,6 +148,7 @@ private:
|
|||
TEST_CASE(one_error_less_files);
|
||||
TEST_CASE(one_error_several_files);
|
||||
TEST_CASE(markup);
|
||||
TEST_CASE(clangTidy);
|
||||
}
|
||||
|
||||
void many_files() {
|
||||
|
@ -246,7 +264,34 @@ private:
|
|||
settings = settingsOld;
|
||||
}
|
||||
|
||||
// TODO: test clang-tidy
|
||||
void clangTidy() {
|
||||
// TODO: we currently only invoke it with ImportProject::FileSettings
|
||||
if (!useFS)
|
||||
return;
|
||||
|
||||
const Settings settingsOld = settings;
|
||||
settings.clangTidy = true;
|
||||
|
||||
#ifdef _WIN32
|
||||
const char exe[] = "clang-tidy.exe";
|
||||
#else
|
||||
const char exe[] = "clang-tidy";
|
||||
#endif
|
||||
|
||||
const std::string file = fprefix() + "_001.cpp";
|
||||
check(1, 0,
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
" return 0;\n"
|
||||
"}",
|
||||
dinit(CheckOptions,
|
||||
$.executeCommandCalled = true,
|
||||
$.exe = exe,
|
||||
$.args = {"-quiet", "-checks=*,-clang-analyzer-*,-llvm*", file, "--"}));
|
||||
ASSERT_EQUALS("Checking " + file + " ...\n", output.str());
|
||||
settings = settingsOld;
|
||||
}
|
||||
|
||||
// TODO: test whole program analysis
|
||||
};
|
||||
|
||||
|
|
|
@ -228,6 +228,9 @@ private:
|
|||
output.str());*/
|
||||
settings = settingsOld;
|
||||
}
|
||||
|
||||
// TODO: test clang-tidy
|
||||
// TODO: test whole program analysis
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestThreadExecutor)
|
||||
|
|
Loading…
Reference in New Issue