Skip to content

Commit

Permalink
aligned code of executor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Oct 5, 2023
1 parent 497b8e3 commit 638bcd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
11 changes: 6 additions & 5 deletions test/testsingleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ class TestSingleExecutorBase : public TestFixture {
}
}

settings.showtime = opt.showtime;
settings.quiet = opt.quiet;
Settings s = settings;
s.showtime = opt.showtime;
s.quiet = opt.quiet;
if (opt.plistOutput)
settings.plistOutput = opt.plistOutput;
s.plistOutput = opt.plistOutput;

bool executeCommandCalled = false;
std::string exe;
Expand All @@ -117,7 +118,7 @@ class TestSingleExecutorBase : public TestFixture {
args = std::move(a);
return EXIT_SUCCESS;
});
cppcheck.settings() = settings;
cppcheck.settings() = s;

std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
scopedfiles.reserve(filemap.size());
Expand All @@ -128,7 +129,7 @@ class TestSingleExecutorBase : public TestFixture {
if (useFS)
filemap.clear();

SingleExecutor executor(cppcheck, filemap, settings, settings.nomsg, *this);
SingleExecutor executor(cppcheck, filemap, s, s.nomsg, *this);
ASSERT_EQUALS(result, executor.check());
ASSERT_EQUALS(opt.executeCommandCalled, executeCommandCalled);
ASSERT_EQUALS(opt.exe, exe);
Expand Down
22 changes: 11 additions & 11 deletions test/testthreadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class TestThreadExecutorBase : public TestFixture {
}
}

Settings settings1 = settings;
settings1.jobs = jobs;
settings1.showtime = opt.showtime;
settings1.quiet = opt.quiet;
Settings s = settings;
s.jobs = jobs;
s.showtime = opt.showtime;
s.quiet = opt.quiet;
if (opt.plistOutput)
settings1.plistOutput = opt.plistOutput;
s.plistOutput = opt.plistOutput;

bool executeCommandCalled = false;
std::string exe;
Expand All @@ -121,7 +121,7 @@ class TestThreadExecutorBase : public TestFixture {
if (useFS)
filemap.clear();

ThreadExecutor executor(filemap, settings1, settings1.nomsg, *this, executeFn);
ThreadExecutor executor(filemap, s, s.nomsg, *this, executeFn);
ASSERT_EQUALS(result, executor.check());
ASSERT_EQUALS(opt.executeCommandCalled, executeCommandCalled);
ASSERT_EQUALS(opt.exe, exe);
Expand Down Expand Up @@ -181,8 +181,7 @@ class TestThreadExecutorBase : public TestFixture {
"{\n"
" char *a = malloc(10);\n"
" return 0;\n"
"}", dinit(CheckOptions,
$.showtime = SHOWTIME_MODES::SHOWTIME_SUMMARY));
"}", dinit(CheckOptions, $.showtime = SHOWTIME_MODES::SHOWTIME_SUMMARY));
}

void many_threads_plist() {
Expand All @@ -194,8 +193,7 @@ class TestThreadExecutorBase : public TestFixture {
"{\n"
" char *a = malloc(10);\n"
" return 0;\n"
"}", dinit(CheckOptions,
$.plistOutput = plistOutput.c_str()));
"}", dinit(CheckOptions, $.plistOutput = plistOutput.c_str()));
}

void no_errors_more_files() {
Expand Down Expand Up @@ -256,7 +254,9 @@ class TestThreadExecutorBase : public TestFixture {
" char *a = malloc(10);\n"
" return 0;\n"
"}",
dinit(CheckOptions, $.filesList = files));
dinit(CheckOptions,
$.quiet = false,
$.filesList = files));
// TODO: order of "Checking" and "checked" is affected by thread
/*TODO_ASSERT_EQUALS("Checking " + fprefix() + "_2.cpp ...\n"
"1/4 files checked 25% done\n"
Expand Down

0 comments on commit 638bcd3

Please sign in to comment.