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
4 changes: 4 additions & 0 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
#endif
}

// TODO: show time *after* the whole program analysis
if (settings.showtime == ShowTime::SUMMARY || settings.showtime == ShowTime::TOP5_SUMMARY)
timerResults.showResults(settings.showtime);

// TODO: is this run again instead of using previously cached results?
returnValue |= cppcheck.analyseWholeProgram(settings.buildDir, mFiles, mFileSettings, stdLogger.getCtuInfo());

Expand Down
4 changes: 1 addition & 3 deletions cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,7 @@ unsigned int ProcessExecutor::check()
}
}

// TODO: wee need to get the timing information from the subprocess
if (mTimerResults && (mSettings.showtime == ShowTime::SUMMARY || mSettings.showtime == ShowTime::TOP5_SUMMARY))
mTimerResults->showResults(mSettings.showtime);
// TODO: we need to get the timing information from the subprocess

return result;
}
Expand Down
4 changes: 1 addition & 3 deletions cli/singleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ unsigned int SingleExecutor::check()
reportStatus(c, mFileSettings.size(), c, mFileSettings.size());
}

// TODO: show time after the whole program analysis
// TODO: CppCheckExecutor::check_internal() is also invoking the whole program analysis - is it run twice?
if (mCppcheck.analyseWholeProgram())
result++;

if (mTimerResults && (mSettings.showtime == ShowTime::SUMMARY || mSettings.showtime == ShowTime::TOP5_SUMMARY))
mTimerResults->showResults(mSettings.showtime);

return result;
}
3 changes: 0 additions & 3 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ unsigned int ThreadExecutor::check()
return v + f.get();
});

if (mTimerResults && (mSettings.showtime == ShowTime::SUMMARY || mSettings.showtime == ShowTime::TOP5_SUMMARY))
mTimerResults->showResults(mSettings.showtime);

return result;
}

Expand Down
1 change: 1 addition & 0 deletions lib/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void Timer::stop()
if (mStart != TimePoint{}) {
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(Clock::now() - mStart);
if (!mResults) {
// TODO: do not print implicitly
std::lock_guard<std::mutex> l(stdCoutLock);
std::cout << (mType == Type::OVERALL ? "Overall time: " : "Check time: " + mName + ": ") << TimerResultsData::durationToString(diff) << std::endl;
} else {
Expand Down
28 changes: 0 additions & 28 deletions test/testprocessexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ class TestProcessExecutorBase : public TestFixture {
TEST_CASE(one_error_less_files);
TEST_CASE(one_error_several_files);
TEST_CASE(showtime_top5_file);
TEST_CASE(showtime_top5_summary);
TEST_CASE(showtime_file);
TEST_CASE(showtime_summary);
TEST_CASE(showtime_file_total);
TEST_CASE(suppress_error_library);
TEST_CASE(unique_errors);
Expand Down Expand Up @@ -255,20 +253,6 @@ class TestProcessExecutorBase : public TestFixture {
TODO_ASSERT_EQUALS(static_cast<long long>(5 + 1 + 1) * 2, 0, cppcheck::count_all_of(output_s, '\n'));
}

void showtime_top5_summary() {
REDIRECT;
check(2, 2, 0,
"int main() {}",
dinit(CheckOptions,
$.showtime = ShowTime::TOP5_SUMMARY));
const std::string output_s = GET_REDIRECT_OUTPUT;
// once: top5 results + overall + empty line
TODO_ASSERT_EQUALS(5 + 1 + 1, 1, cppcheck::count_all_of(output_s, '\n'));
// should only report the top5 once
ASSERT(output_s.find("1 result(s)") == std::string::npos);
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
}

void showtime_file() {
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
check(2, 2, 0,
Expand All @@ -279,18 +263,6 @@ class TestProcessExecutorBase : public TestFixture {
TODO_ASSERT_EQUALS(2, 0, cppcheck::count_all_of(output_s, "Overall time:"));
}

void showtime_summary() {
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
check(2, 2, 0,
"int main() {}",
dinit(CheckOptions,
$.showtime = ShowTime::SUMMARY));
const std::string output_s = GET_REDIRECT_OUTPUT;
// should only report the actual summary once
ASSERT(output_s.find("1 result(s)") == std::string::npos);
TODO_ASSERT(output_s.find("2 result(s)") != std::string::npos);
}

void showtime_file_total() {
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
check(2, 2, 0,
Expand Down
28 changes: 0 additions & 28 deletions test/testsingleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ class TestSingleExecutorBase : public TestFixture {
TEST_CASE(one_error_less_files);
TEST_CASE(one_error_several_files);
TEST_CASE(showtime_top5_file);
TEST_CASE(showtime_top5_summary);
TEST_CASE(showtime_file);
TEST_CASE(showtime_summary);
TEST_CASE(showtime_file_total);
TEST_CASE(suppress_error_library);
TEST_CASE(unique_errors);
Expand Down Expand Up @@ -247,20 +245,6 @@ class TestSingleExecutorBase : public TestFixture {
ASSERT_EQUALS((5 + 1 + 1) * 2LL, cppcheck::count_all_of(output_s, '\n'));
}

void showtime_top5_summary() {
REDIRECT;
check(2, 0,
"int main() {}",
dinit(CheckOptions,
$.showtime = ShowTime::TOP5_SUMMARY));
const std::string output_s = GET_REDIRECT_OUTPUT;
// once: top5 results + newline
ASSERT_EQUALS(5 + 1, cppcheck::count_all_of(output_s, '\n'));
// should only report the top5 once
ASSERT(output_s.find("1 result(s)") == std::string::npos);
ASSERT(output_s.find("2 result(s)") != std::string::npos);
}

void showtime_file() {
REDIRECT;
check(2, 0,
Expand All @@ -271,18 +255,6 @@ class TestSingleExecutorBase : public TestFixture {
ASSERT_EQUALS(0, cppcheck::count_all_of(output_s, "Overall time:"));
}

void showtime_summary() {
REDIRECT;
check(2, 0,
"int main() {}",
dinit(CheckOptions,
$.showtime = ShowTime::SUMMARY));
const std::string output_s = GET_REDIRECT_OUTPUT;
// should only report the actual summary once
ASSERT(output_s.find("1 result(s)") == std::string::npos);
ASSERT(output_s.find("2 result(s)") != std::string::npos);
}

void showtime_file_total() {
REDIRECT;
check(2, 0,
Expand Down
28 changes: 0 additions & 28 deletions test/testthreadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ class TestThreadExecutorBase : public TestFixture {
TEST_CASE(one_error_less_files);
TEST_CASE(one_error_several_files);
TEST_CASE(showtime_top5_file);
TEST_CASE(showtime_top5_summary);
TEST_CASE(showtime_file);
TEST_CASE(showtime_summary);
TEST_CASE(showtime_file_total);
TEST_CASE(suppress_error_library);
TEST_CASE(unique_errors);
Expand Down Expand Up @@ -255,20 +253,6 @@ class TestThreadExecutorBase : public TestFixture {
ASSERT_EQUALS((5 + 1 + 1) * 2LL, cppcheck::count_all_of(output_s, '\n'));
}

void showtime_top5_summary() {
REDIRECT;
check(2, 2, 0,
"int main() {}",
dinit(CheckOptions,
$.showtime = ShowTime::TOP5_SUMMARY));
const std::string output_s = GET_REDIRECT_OUTPUT;
// once: top5 results + newline
ASSERT_EQUALS(5 + 1, cppcheck::count_all_of(output_s, '\n'));
// should only report the top5 once
ASSERT(output_s.find("1 result(s)") == std::string::npos);
ASSERT(output_s.find("2 result(s)") != std::string::npos);
}

void showtime_file() {
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
check(2, 2, 0,
Expand All @@ -279,18 +263,6 @@ class TestThreadExecutorBase : public TestFixture {
ASSERT_EQUALS(0, cppcheck::count_all_of(output_s, "Overall time:"));
}

void showtime_summary() {
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
check(2, 2, 0,
"int main() {}",
dinit(CheckOptions,
$.showtime = ShowTime::SUMMARY));
const std::string output_s = GET_REDIRECT_OUTPUT;
// should only report the actual summary once
ASSERT(output_s.find("1 result(s)") == std::string::npos);
ASSERT(output_s.find("2 result(s)") != std::string::npos);
}

void showtime_file_total() {
REDIRECT; // should not cause TSAN failures as the showtime logging is synchronized
check(2, 2, 0,
Expand Down
Loading