File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -722,7 +722,7 @@ cli/stacktrace.o: cli/stacktrace.cpp cli/stacktrace.h lib/config.h lib/utils.h
722722cli/threadexecutor.o : cli/threadexecutor.cpp cli/executor.h cli/threadexecutor.h lib/addoninfo.h lib/check.h lib/checkers.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h
723723 $(CXX ) ${INCLUDE_FOR_CLI} $(CPPFLAGS ) $(CXXFLAGS ) -c -o $@ cli/threadexecutor.cpp
724724
725- test/fixture.o : test/fixture.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/xml.h test/fixture.h test/helpers.h test/options.h test/redirect.h
725+ test/fixture.o : test/fixture.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/timer.h lib/ tokenize.h lib/tokenlist.h lib/utils.h lib/xml.h test/fixture.h test/helpers.h test/options.h test/redirect.h
726726 $(CXX ) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS ) $(CXXFLAGS ) -c -o $@ test/fixture.cpp
727727
728728test/helpers.o : test/helpers.cpp cli/filelister.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/xml.h test/helpers.h
@@ -731,7 +731,7 @@ test/helpers.o: test/helpers.cpp cli/filelister.h externals/simplecpp/simplecpp.
731731test/main.o : test/main.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h test/options.h
732732 $(CXX ) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS ) $(CXXFLAGS ) -c -o $@ test/main.cpp
733733
734- test/options.o : test/options.cpp test/options.h
734+ test/options.o : test/options.cpp lib/config.h lib/timer.h test/options.h
735735 $(CXX ) ${INCLUDE_FOR_TEST} ${CFLAGS_FOR_TEST} $(CPPFLAGS ) $(CXXFLAGS ) -c -o $@ test/options.cpp
736736
737737test/test64bit.o : test/test64bit.cpp lib/addoninfo.h lib/check.h lib/check64bit.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h
Original file line number Diff line number Diff line change 2323#include " library.h"
2424#include " options.h"
2525#include " redirect.h"
26+ #include " timer.h"
2627
2728#include < algorithm>
2829#include < cstdio>
@@ -101,12 +102,14 @@ bool TestFixture::prepareTest(const char testname[])
101102 // Tests will be executed - prepare them
102103 mTestname = testname;
103104 ++countTests;
105+ std::string fullTestName = classname + " ::" + mTestname ;
104106 if (quiet_tests) {
105107 std::putchar (' .' ); // Use putchar to write through redirection of std::cout/cerr
106108 std::fflush (stdout);
107109 } else {
108- std::cout << classname << " :: " << mTestname << std::endl;
110+ std::cout << fullTestName << std::endl;
109111 }
112+ mTimer .reset (new Timer (fullTestName, ShowTime::TOP5_SUMMARY, timerResults));
110113 return !dry_run;
111114 }
112115 return false ;
@@ -116,6 +119,10 @@ void TestFixture::teardownTest()
116119{
117120 teardownTestInternal ();
118121
122+ // TODO: print more detailed data
123+ if (mTimer )
124+ mTimer ->stop ();
125+
119126 {
120127 const std::string s = errout_str ();
121128 if (!s.empty ())
@@ -381,6 +388,7 @@ void TestFixture::processOptions(const options& args)
381388 quiet_tests = args.quiet ();
382389 dry_run = args.dry_run ();
383390 exename = args.exe ();
391+ timerResults = args.timer_results ();
384392}
385393
386394std::size_t TestFixture::runTests (const options& args)
Original file line number Diff line number Diff line change 4242
4343class options ;
4444class Tokenizer ;
45+ class Timer ;
46+ class TimerResultsIntf ;
4547
4648class TestFixture : public ErrorLogger {
4749private:
@@ -60,6 +62,7 @@ class TestFixture : public ErrorLogger {
6062 bool quiet_tests{};
6163 bool dry_run{};
6264 bool mNewTemplate {};
65+ TimerResultsIntf* timerResults{};
6366
6467 virtual void run () = 0;
6568
@@ -284,6 +287,8 @@ class TestFixture : public ErrorLogger {
284287 std::ostringstream mOutput ;
285288 std::ostringstream mErrout ;
286289
290+ std::unique_ptr<Timer> mTimer ;
291+
287292 void reportOut (const std::string &outmsg, Color c = Color::Reset) override ;
288293 void reportErr (const ErrorMessage &msg) override ;
289294 void reportMetric (const std::string &metric) override
Original file line number Diff line number Diff line change 1616
1717#include " options.h"
1818
19+ #include " timer.h"
20+
1921options::options (int argc, const char * const argv[])
2022 : mWhichTests(argv + 1 , argv + argc)
2123 ,mQuiet(mWhichTests .count(" -q" ) != 0)
@@ -25,6 +27,9 @@ options::options(int argc, const char* const argv[])
2527 ,mExcludeTests(mWhichTests .count(" -x" ) != 0)
2628 ,mExe(argv[0 ])
2729{
30+ if (mWhichTests .count (" -t" ) != 0 )
31+ mTimerResults .reset (new TimerResults);
32+
2833 for (auto it = mWhichTests .cbegin (); it != mWhichTests .cend ();) {
2934 if (!it->empty () && (((*it)[0 ] == ' -' ) || (it->find (" ::" ) != std::string::npos && mWhichTests .count (it->substr (0 , it->find (" ::" ))))))
3035 it = mWhichTests .erase (it);
@@ -37,6 +42,12 @@ options::options(int argc, const char* const argv[])
3742 }
3843}
3944
45+ options::~options ()
46+ {
47+ if (mTimerResults )
48+ mTimerResults ->showResults (ShowTime::TOP5_FILE);
49+ }
50+
4051bool options::quiet () const
4152{
4253 return mQuiet ;
@@ -71,3 +82,8 @@ bool options::exclude_tests() const
7182{
7283 return mExcludeTests ;
7384}
85+
86+ TimerResultsIntf* options::timer_results () const
87+ {
88+ return mTimerResults .get ();
89+ }
Original file line number Diff line number Diff line change 2020#include < set>
2121#include < string>
2222
23+ class TimerResults ;
24+
2325/* *
2426 * @brief Class to parse command-line parameters for ./testrunner .
2527 * Has getters for available switches and parameters.
@@ -29,6 +31,7 @@ class options {
2931public:
3032 /* * Call from main() to populate object */
3133 options (int argc, const char * const argv[]);
34+ ~options ();
3235 /* * Don't print the name of each method being tested. */
3336 bool quiet () const ;
3437 /* * Print help. */
@@ -39,6 +42,8 @@ class options {
3942 bool dry_run () const ;
4043 /* * Exclude provided lists of tests. */
4144 bool exclude_tests () const ;
45+ /* * The timer results. */
46+ TimerResultsIntf* timer_results () const ;
4247 /* * Which test should be run. Empty string means 'all tests' */
4348 const std::set<std::string>& which_test () const ;
4449
@@ -55,6 +60,7 @@ class options {
5560 const bool mSummary ;
5661 const bool mDryRun ;
5762 const bool mExcludeTests ;
63+ std::unique_ptr<TimerResults> mTimerResults ;
5864 std::string mExe ;
5965};
6066
You can’t perform that action at this time.
0 commit comments