@@ -49,6 +49,7 @@ class TestProcessExecutor : public TestFixture {
4949 struct CheckOptions
5050 {
5151 CheckOptions () DINIT_NOEXCEPT = default ;
52+ bool quiet = true ;
5253 SHOWTIME_MODES showtime = SHOWTIME_MODES::SHOWTIME_NONE;
5354 const char * plistOutput = nullptr ;
5455 std::vector<std::string> filesList;
@@ -79,6 +80,7 @@ class TestProcessExecutor : public TestFixture {
7980
8081 settings.jobs = jobs;
8182 settings.showtime = opt.showtime ;
83+ settings.quiet = opt.quiet ;
8284 if (opt.plistOutput )
8385 settings.plistOutput = opt.plistOutput ;
8486 // TODO: test with settings.project.fileSettings;
@@ -103,6 +105,12 @@ class TestProcessExecutor : public TestFixture {
103105 TEST_CASE (one_error_less_files);
104106 TEST_CASE (one_error_several_files);
105107 TEST_CASE (markup);
108+ TEST_CASE (showtime_top5);
109+ TEST_CASE (showtime_file);
110+ TEST_CASE (showtime_summary);
111+ TEST_CASE (showtime_top5_j);
112+ TEST_CASE (showtime_file_j);
113+ TEST_CASE (showtime_summary_j);
106114#endif // !WIN32
107115 }
108116
@@ -118,6 +126,7 @@ class TestProcessExecutor : public TestFixture {
118126 check (2 , 3 , 3 , oss.str ());
119127 }
120128
129+ // TODO: check the output
121130 void many_threads () {
122131 check (16 , 100 , 100 ,
123132 " int main()\n "
@@ -208,7 +217,9 @@ class TestProcessExecutor : public TestFixture {
208217 " char *a = malloc(10);\n "
209218 " return 0;\n "
210219 " }" ,
211- dinit (CheckOptions, $.filesList = files));
220+ dinit (CheckOptions,
221+ $.quiet = false ,
222+ $.filesList = files));
212223 // TODO: order of "Checking" and "checked" is affected by thread
213224 /* TODO_ASSERT_EQUALS("Checking " + fprefix() + "_2.cpp ...\n"
214225 "1/4 files checked 25% done\n"
@@ -229,6 +240,70 @@ class TestProcessExecutor : public TestFixture {
229240 output.str());*/
230241 settings = settingsOld;
231242 }
243+
244+
245+ // TODO: provide data which actually shows values above 0
246+
247+ // TODO: should this be logged only once like summary?
248+ void showtime_top5 () {
249+ REDIRECT;
250+ check (1 , 2 , 0 ,
251+ " int main() {}" ,
252+ true , SHOWTIME_MODES::SHOWTIME_TOP5);
253+ // for each file: top5 results + overall + empty line
254+ const std::string output_s = GET_REDIRECT_OUTPUT;
255+ TODO_ASSERT_EQUALS ((5 + 1 + 1 ) * 2 , 0 , cppcheck::find_all_of (output_s, ' \n ' ));
256+ }
257+
258+ void showtime_file () {
259+ REDIRECT;
260+ check (1 , 2 , 0 ,
261+ " int main() {}" ,
262+ true , SHOWTIME_MODES::SHOWTIME_FILE);
263+ const std::string output_s = GET_REDIRECT_OUTPUT;
264+ TODO_ASSERT_EQUALS (2 , 0 , cppcheck::find_all_of (output_s, " Overall time:" ));
265+ }
266+
267+ void showtime_summary () {
268+ REDIRECT;
269+ check (1 , 2 , 0 ,
270+ " int main() {}" ,
271+ true , SHOWTIME_MODES::SHOWTIME_SUMMARY);
272+ const std::string output_s = GET_REDIRECT_OUTPUT;
273+ // should only report the actual summary once
274+ ASSERT (output_s.find (" 1 result(s)" ) == std::string::npos);
275+ TODO_ASSERT (output_s.find (" 2 result(s)" ) != std::string::npos);
276+ }
277+
278+ void showtime_top5_j () {
279+ REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
280+ check (2 , 2 , 0 ,
281+ " int main() {}" ,
282+ true , SHOWTIME_MODES::SHOWTIME_TOP5);
283+ // for each file: top5 results + overall + empty line
284+ const std::string output_s = GET_REDIRECT_OUTPUT;
285+ TODO_ASSERT_EQUALS ((5 + 1 + 1 ) * 2 , 0 , cppcheck::find_all_of (output_s, ' \n ' ));
286+ }
287+
288+ void showtime_file_j () {
289+ REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
290+ check (2 , 2 , 0 ,
291+ " int main() {}" ,
292+ true , SHOWTIME_MODES::SHOWTIME_FILE);
293+ const std::string output_s = GET_REDIRECT_OUTPUT;
294+ TODO_ASSERT_EQUALS (2 , 0 , cppcheck::find_all_of (output_s, " Overall time:" ));
295+ }
296+
297+ void showtime_summary_j () {
298+ REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
299+ check (2 , 2 , 0 ,
300+ " int main() {}" ,
301+ true , SHOWTIME_MODES::SHOWTIME_SUMMARY);
302+ const std::string output_s = GET_REDIRECT_OUTPUT;
303+ // should only report the actual summary once
304+ ASSERT (output_s.find (" 1 result(s)" ) == std::string::npos);
305+ TODO_ASSERT (output_s.find (" 2 result(s)" ) != std::string::npos);
306+ }
232307};
233308
234309REGISTER_TEST (TestProcessExecutor)
0 commit comments