Skip to content
Open
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
7 changes: 2 additions & 5 deletions cli/cppcheckexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ struct Suppressions;
*/
class CppCheckExecutor {
public:
friend class TestSuppressions;

/**
* Constructor
*/
Expand All @@ -61,17 +59,16 @@ class CppCheckExecutor {
*/
int check(int argc, const char* const argv[]);

private:
protected:

/**
* Execute a shell command and read the output from it. Returns exitcode of the executed command,.
*/
static int executeCommand(std::string exe, std::vector<std::string> args, std::string redirect, std::string &output_);

protected:

static bool reportUnmatchedSuppressions(const Settings &settings, const SuppressionList& suppressions, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger);

private:
/**
* Wrapper around check_internal
* - installs optional platform dependent signal handling
Expand Down
29 changes: 17 additions & 12 deletions test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class TestSuppressions : public TestFixture {

private:

class CppCheckExecutorTest final : public CppCheckExecutor
{
friend class TestSuppressions;
};

const std::string templateFormat{"{callstack}: ({severity}) {inconclusive:inconclusive: }{message}"};

void run() override {
Expand Down Expand Up @@ -289,7 +294,7 @@ class TestSuppressions : public TestFixture {
SingleExecutor executor(cppCheck, filelist, fileSettings, settings, supprs, *this, nullptr);
unsigned int exitCode = executor.check();

const bool err = CppCheckExecutor::reportUnmatchedSuppressions(settings, supprs.nomsg, filelist, fileSettings, *this);
const bool err = CppCheckExecutorTest::reportUnmatchedSuppressions(settings, supprs.nomsg, filelist, fileSettings, *this);
if (err && exitCode == 0)
exitCode = 1;

Expand Down Expand Up @@ -335,10 +340,10 @@ class TestSuppressions : public TestFixture {
if (useFS)
filelist.clear();

ThreadExecutor executor(filelist, fileSettings, settings, supprs, *this, nullptr, CppCheckExecutor::executeCommand);
ThreadExecutor executor(filelist, fileSettings, settings, supprs, *this, nullptr, CppCheckExecutorTest::executeCommand);
unsigned int exitCode = executor.check();

const bool err = CppCheckExecutor::reportUnmatchedSuppressions(settings, supprs.nomsg, filelist, fileSettings, *this);
const bool err = CppCheckExecutorTest::reportUnmatchedSuppressions(settings, supprs.nomsg, filelist, fileSettings, *this);
if (err && exitCode == 0)
exitCode = 1;

Expand Down Expand Up @@ -385,10 +390,10 @@ class TestSuppressions : public TestFixture {
if (useFS)
filelist.clear();

ProcessExecutor executor(filelist, fileSettings, settings, supprs, *this, nullptr, CppCheckExecutor::executeCommand);
ProcessExecutor executor(filelist, fileSettings, settings, supprs, *this, nullptr, CppCheckExecutorTest::executeCommand);
unsigned int exitCode = executor.check();

const bool err = CppCheckExecutor::reportUnmatchedSuppressions(settings, supprs.nomsg, filelist, fileSettings, *this);
const bool err = CppCheckExecutorTest::reportUnmatchedSuppressions(settings, supprs.nomsg, filelist, fileSettings, *this);
if (err && exitCode == 0)
exitCode = 1;

Expand Down Expand Up @@ -1534,7 +1539,7 @@ class TestSuppressions : public TestFixture {
// No unmatched suppression
{
SuppressionList suppressions;
ASSERT_EQUALS(false, CppCheckExecutor::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS("", errout_str());
}

Expand All @@ -1543,7 +1548,7 @@ class TestSuppressions : public TestFixture {
SuppressionList suppressions;
addCheckedSuppression(suppressions, {"abc", "a.c", 10U});
addCheckedSuppression(suppressions, {"unmatchedSuppression", "*", SuppressionList::Suppression::NO_LINE});
ASSERT_EQUALS(false, CppCheckExecutor::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS("", errout_str());
}

Expand All @@ -1552,7 +1557,7 @@ class TestSuppressions : public TestFixture {
SuppressionList suppressions;
addCheckedSuppression(suppressions, {"abc", "a.c", 10U});
addCheckedSuppression(suppressions, {"unmatchedSuppression", "", SuppressionList::Suppression::NO_LINE});
ASSERT_EQUALS(false, CppCheckExecutor::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS("", errout_str());
}

Expand All @@ -1561,7 +1566,7 @@ class TestSuppressions : public TestFixture {
SuppressionList suppressions;
addCheckedSuppression(suppressions, {"abc", "a.c", 10U});
addCheckedSuppression(suppressions, {"unmatchedSuppression", "a.c", SuppressionList::Suppression::NO_LINE});
ASSERT_EQUALS(false, CppCheckExecutor::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS("", errout_str());
}

Expand All @@ -1570,7 +1575,7 @@ class TestSuppressions : public TestFixture {
SuppressionList suppressions;
addCheckedSuppression(suppressions, {"abc", "a.c", 10U});
addCheckedSuppression(suppressions, {"unmatchedSuppression", "a.c", 10U});
ASSERT_EQUALS(false, CppCheckExecutor::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS(false, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS("", errout_str());
}

Expand All @@ -1579,7 +1584,7 @@ class TestSuppressions : public TestFixture {
SuppressionList suppressions;
addCheckedSuppression(suppressions, {"abc", "a.c", 10U});
addCheckedSuppression(suppressions, {"unmatchedSuppression", "b.c", SuppressionList::Suppression::NO_LINE});
ASSERT_EQUALS(true, CppCheckExecutor::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS(true, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS("[a.c:10:0]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str());
}

Expand All @@ -1588,7 +1593,7 @@ class TestSuppressions : public TestFixture {
SuppressionList suppressions;
addCheckedSuppression(suppressions, {"abc", "a.c", 10U});
addCheckedSuppression(suppressions, {"unmatchedSuppression", "a.c", 1U});
ASSERT_EQUALS(true, CppCheckExecutor::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS(true, CppCheckExecutorTest::reportUnmatchedSuppressions(settingsDefault, suppressions, files, fs, *this));
ASSERT_EQUALS("[a.c:10:0]: (information) Unmatched suppression: abc [unmatchedSuppression]\n", errout_str());
}
}
Expand Down
Loading