Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions cli/singleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down Expand Up @@ -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++;
}
}
Expand Down
1 change: 1 addition & 0 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class ThreadData
} else {
// Read file from a file
result = fileChecker.check(*file);
// TODO: call analyseClangTidy()?
}
return result;
}
Expand Down
3 changes: 3 additions & 0 deletions test/testprocessexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ class TestProcessExecutor : public TestFixture {
output.str());*/
settings = settingsOld;
}

// TODO: test clang-tidy
// TODO: test whole program analysis
};

REGISTER_TEST(TestProcessExecutor)
51 changes: 48 additions & 3 deletions test/testsingleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class TestSingleExecutorBase : public TestFixture {
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 = {}) {
Expand Down Expand Up @@ -101,9 +104,16 @@ class TestSingleExecutorBase : public TestFixture {
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;

Expand All @@ -119,6 +129,13 @@ class TestSingleExecutorBase : public TestFixture {
// TODO: test with settings.project.fileSettings;
SingleExecutor executor(cppcheck, filemap, settings, *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 {
Expand All @@ -131,6 +148,7 @@ class TestSingleExecutorBase : public TestFixture {
TEST_CASE(one_error_less_files);
TEST_CASE(one_error_several_files);
TEST_CASE(markup);
TEST_CASE(clangTidy);
}

void many_files() {
Expand Down Expand Up @@ -246,7 +264,34 @@ class TestSingleExecutorBase : public TestFixture {
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
};

Expand Down
3 changes: 3 additions & 0 deletions test/testthreadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ class TestThreadExecutor : public TestFixture {
output.str());*/
settings = settingsOld;
}

// TODO: test clang-tidy
// TODO: test whole program analysis
};

REGISTER_TEST(TestThreadExecutor)