Skip to content

Commit eca4612

Browse files
committed
print timing information in the proper places for SingleExecutor
1 parent 1764b61 commit eca4612

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/color.h lib/config.h lib/err
663663
cli/processexecutor.o: cli/processexecutor.cpp cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
664664
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/processexecutor.cpp
665665

666-
cli/singleexecutor.o: cli/singleexecutor.cpp cli/executor.h cli/singleexecutor.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
666+
cli/singleexecutor.o: cli/singleexecutor.cpp cli/executor.h cli/singleexecutor.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h
667667
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/singleexecutor.cpp
668668

669669
cli/stacktrace.o: cli/stacktrace.cpp cli/stacktrace.h lib/config.h lib/utils.h

cli/singleexecutor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "importproject.h"
2323
#include "library.h"
2424
#include "settings.h"
25+
#include "timer.h"
2526

2627
#include <cassert>
2728
#include <list>
@@ -110,5 +111,8 @@ unsigned int SingleExecutor::check()
110111
if (mCppcheck.analyseWholeProgram())
111112
result++;
112113

114+
if (mSettings.showtime == SHOWTIME_MODES::SHOWTIME_SUMMARY || mSettings.showtime == SHOWTIME_MODES::SHOWTIME_TOP5_SUMMARY)
115+
CppCheck::printTimerResults(mSettings.showtime);
116+
113117
return result;
114118
}

lib/cppcheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,6 @@ CppCheck::~CppCheck()
468468
mFileInfo.pop_back();
469469
}
470470

471-
if (mSettings.showtime == SHOWTIME_MODES::SHOWTIME_FILE || mSettings.showtime == SHOWTIME_MODES::SHOWTIME_TOP5_FILE)
472-
printTimerResults(mSettings.showtime);
473-
474471
if (mPlistFile.is_open()) {
475472
mPlistFile << ErrorLogger::plistFooter();
476473
mPlistFile.close();
@@ -1102,6 +1099,9 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
11021099

11031100
mErrorList.clear();
11041101

1102+
if (mSettings.showtime == SHOWTIME_MODES::SHOWTIME_FILE || mSettings.showtime == SHOWTIME_MODES::SHOWTIME_TOP5_FILE)
1103+
printTimerResults(mSettings.showtime);
1104+
11051105
return mExitCode;
11061106
}
11071107

test/testsingleexecutor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class TestSingleExecutorBase : public TestFixture {
307307
$.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_FILE));
308308
const std::string output_s = GET_REDIRECT_OUTPUT;
309309
// for each file: top5 results + overall + empty line
310-
TODO_ASSERT_EQUALS((5 + 1 + 1) * 2, (5 + 1 + 1), cppcheck::count_all_of(output_s, '\n'));
310+
ASSERT_EQUALS((5 + 1 + 1) * 2, cppcheck::count_all_of(output_s, '\n'));
311311
}
312312

313313
void showtime_top5_summary() {
@@ -318,10 +318,10 @@ class TestSingleExecutorBase : public TestFixture {
318318
$.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_SUMMARY));
319319
const std::string output_s = GET_REDIRECT_OUTPUT;
320320
// once: top5 results + overall + empty line
321-
TODO_ASSERT_EQUALS(5 + 1 + 1, 0, cppcheck::count_all_of(output_s, '\n'));
321+
ASSERT_EQUALS(5 + 1 + 1, cppcheck::count_all_of(output_s, '\n'));
322322
// should only report the top5 once
323323
ASSERT(output_s.find("1 result(s)") == std::string::npos);
324-
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
324+
ASSERT(output_s.find("2 result(s)") != std::string::npos);
325325
}
326326

327327
void showtime_file() {
@@ -331,7 +331,7 @@ class TestSingleExecutorBase : public TestFixture {
331331
dinit(CheckOptions,
332332
$.showtime = SHOWTIME_MODES::SHOWTIME_FILE));
333333
const std::string output_s = GET_REDIRECT_OUTPUT;
334-
TODO_ASSERT_EQUALS(2, 1, cppcheck::count_all_of(output_s, "Overall time:"));
334+
ASSERT_EQUALS(2, cppcheck::count_all_of(output_s, "Overall time:"));
335335
}
336336

337337
void showtime_summary() {
@@ -343,7 +343,7 @@ class TestSingleExecutorBase : public TestFixture {
343343
const std::string output_s = GET_REDIRECT_OUTPUT;
344344
// should only report the actual summary once
345345
ASSERT(output_s.find("1 result(s)") == std::string::npos);
346-
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
346+
ASSERT(output_s.find("2 result(s)") != std::string::npos);
347347
}
348348

349349
// TODO: test whole program analysis

0 commit comments

Comments
 (0)