Skip to content

Commit 70d3b1e

Browse files
committed
TestSingleExecutor: applied changes from other executor tests / marked failed tests with TODO
1 parent 9a7b13c commit 70d3b1e

1 file changed

Lines changed: 55 additions & 7 deletions

File tree

test/testsingleexecutor.cpp

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class TestSingleExecutorBase : public TestFixture {
6464
struct CheckOptions
6565
{
6666
CheckOptions() DINIT_NOEXCEPT = default;
67+
bool quiet = true;
6768
SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE;
6869
const char* plistOutput = nullptr;
6970
std::vector<std::string> filesList;
@@ -99,6 +100,7 @@ class TestSingleExecutorBase : public TestFixture {
99100
}
100101

101102
settings.showtime = opt.showtime;
103+
settings.quiet = opt.quiet;
102104
if (opt.plistOutput)
103105
settings.plistOutput = opt.plistOutput;
104106
// NOLINTNEXTLINE(performance-unnecessary-value-param)
@@ -131,26 +133,25 @@ class TestSingleExecutorBase : public TestFixture {
131133
TEST_CASE(one_error_less_files);
132134
TEST_CASE(one_error_several_files);
133135
TEST_CASE(markup);
136+
TEST_CASE(showtime_top5_file);
137+
TEST_CASE(showtime_top5_summary);
138+
TEST_CASE(showtime_file);
139+
TEST_CASE(showtime_summary);
134140
}
135141

136142
void many_files() {
137-
const Settings settingsOld = settings;
138-
settings.quiet = false;
139-
140143
check(100, 100,
141144
"int main()\n"
142145
"{\n"
143146
" char *a = malloc(10);\n"
144147
" return 0;\n"
145-
"}");
148+
"}", false);
146149
std::string expected;
147150
for (int i = 1; i <= 100; ++i) {
148151
expected += "Checking " + fprefix() + "_" + zpad3(i) + ".cpp ...\n";
149152
expected += std::to_string(i) + "/100 files checked " + std::to_string(i) + "% done\n";
150153
}
151154
ASSERT_EQUALS(expected, output.str());
152-
153-
settings = settingsOld;
154155
}
155156

156157
void many_files_showtime() {
@@ -233,7 +234,9 @@ class TestSingleExecutorBase : public TestFixture {
233234
" char *a = malloc(10);\n"
234235
" return 0;\n"
235236
"}",
236-
dinit(CheckOptions, $.filesList = files));
237+
dinit(CheckOptions,
238+
$.quiet = false,
239+
$.filesList = files));
237240
// TODO: filter out the "files checked" messages
238241
ASSERT_EQUALS("Checking " + fprefix() + "_2.cpp ...\n"
239242
"1/4 files checked 25% done\n"
@@ -246,6 +249,51 @@ class TestSingleExecutorBase : public TestFixture {
246249
settings = settingsOld;
247250
}
248251

252+
// TODO: provide data which actually shows values above 0
253+
254+
void showtime_top5_file() {
255+
REDIRECT;
256+
check(2, 0,
257+
"int main() {}",
258+
true, SHOWTIME_MODES::SHOWTIME_TOP5_FILE);
259+
const std::string output_s = GET_REDIRECT_OUTPUT;
260+
// for each file: top5 results + overall + empty line
261+
TODO_ASSERT_EQUALS((5 + 1 + 1) * 2, (5 + 1 + 1), cppcheck::count_all_of(output_s, '\n'));
262+
}
263+
264+
void showtime_top5_summary() {
265+
REDIRECT;
266+
check(2, 0,
267+
"int main() {}",
268+
true, SHOWTIME_MODES::SHOWTIME_TOP5_SUMMARY);
269+
const std::string output_s = GET_REDIRECT_OUTPUT;
270+
// once: top5 results + overall + empty line
271+
TODO_ASSERT_EQUALS(5 + 1 + 1, 0, cppcheck::count_all_of(output_s, '\n'));
272+
// should only report the top5 once
273+
ASSERT(output_s.find("1 result(s)") == std::string::npos);
274+
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
275+
}
276+
277+
void showtime_file() {
278+
REDIRECT;
279+
check(2, 0,
280+
"int main() {}",
281+
true, SHOWTIME_MODES::SHOWTIME_FILE);
282+
const std::string output_s = GET_REDIRECT_OUTPUT;
283+
TODO_ASSERT_EQUALS(2, 1, cppcheck::count_all_of(output_s, "Overall time:"));
284+
}
285+
286+
void showtime_summary() {
287+
REDIRECT;
288+
check(2, 0,
289+
"int main() {}",
290+
true, SHOWTIME_MODES::SHOWTIME_SUMMARY);
291+
const std::string output_s = GET_REDIRECT_OUTPUT;
292+
// should only report the actual summary once
293+
ASSERT(output_s.find("1 result(s)") == std::string::npos);
294+
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
295+
}
296+
249297
// TODO: test clang-tidy
250298
// TODO: test whole program analysis
251299
};

0 commit comments

Comments
 (0)