diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index d5980db6f70..ad4d3acf312 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -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()); diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index 7b750fdc26b..f4b3729268f 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -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; } diff --git a/cli/singleexecutor.cpp b/cli/singleexecutor.cpp index b84aa70772e..d710a4d4c57 100644 --- a/cli/singleexecutor.cpp +++ b/cli/singleexecutor.cpp @@ -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; } diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 8e8893e72cb..b8581d7e772 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -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; } diff --git a/lib/timer.cpp b/lib/timer.cpp index a135ad13233..f29c3b55e53 100644 --- a/lib/timer.cpp +++ b/lib/timer.cpp @@ -109,6 +109,7 @@ void Timer::stop() if (mStart != TimePoint{}) { auto diff = std::chrono::duration_cast(Clock::now() - mStart); if (!mResults) { + // TODO: do not print implicitly std::lock_guard l(stdCoutLock); std::cout << (mType == Type::OVERALL ? "Overall time: " : "Check time: " + mName + ": ") << TimerResultsData::durationToString(diff) << std::endl; } else { diff --git a/test/testprocessexecutor.cpp b/test/testprocessexecutor.cpp index 927c1f44723..5095b095dfa 100644 --- a/test/testprocessexecutor.cpp +++ b/test/testprocessexecutor.cpp @@ -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); @@ -255,20 +253,6 @@ class TestProcessExecutorBase : public TestFixture { TODO_ASSERT_EQUALS(static_cast(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, @@ -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, diff --git a/test/testsingleexecutor.cpp b/test/testsingleexecutor.cpp index 3fb4c778043..a977153758c 100644 --- a/test/testsingleexecutor.cpp +++ b/test/testsingleexecutor.cpp @@ -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); @@ -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, @@ -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, diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index c99d7753d12..19e1f6bbc9a 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -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); @@ -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, @@ -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,