31 #include "Verbosity.h"
33 #include "TestRunner.h"
34 #include "string_util.h"
42 TestRunner* TestRunner::getRunner() {
43 static TestRunner singletonRunner;
44 return &singletonRunner;
51 void TestRunner::setLifeCycleMatchingPattern(
const char* pattern,
53 size_t length = strlen(pattern);
54 if (length > 0 && pattern[length - 1] ==
'*') {
63 if ((*p)->getName().compareToN(pattern, length) == 0) {
64 (*p)->setLifeCycle(lifeCycle);
69 void TestRunner::setLifeCycleMatchingPattern(
const char* testClass,
70 const char* pattern, uint8_t lifeCycle) {
76 char fullPattern[kMaxPatternLength];
77 bool status = internal::string_join(fullPattern, kMaxPatternLength,
'_',
81 setLifeCycleMatchingPattern(fullPattern, lifeCycle);
86 uint16_t TestRunner::countTests() {
101 void printSeconds(Print* printer,
unsigned long timeMillis) {
102 int s = timeMillis / 1000;
103 int ms = timeMillis % 1000;
106 if (ms < 100) printer->print(
'0');
107 if (ms < 10) printer->print(
'0');
113 void TestRunner::printStartRunner()
const {
117 printer->print(F(
"TestRunner started on "));
118 printer->print(mCount);
119 printer->println(F(
" test(s)."));
122 void TestRunner::resolveRun()
const {
126 unsigned long elapsedTime = mEndTime - mStartTime;
127 printer->print(F(
"TestRunner duration: "));
128 printSeconds(printer, elapsedTime);
129 printer->println(
" seconds.");
131 printer->print(F(
"TestRunner summary: "));
132 printer->print(mPassedCount);
133 printer->print(F(
" passed, "));
134 printer->print(mFailedCount);
135 printer->print(F(
" failed, "));
136 printer->print(mSkippedCount);
137 printer->print(F(
" skipped, "));
138 printer->print(mExpiredCount);
139 printer->print(F(
" timed out, out of "));
140 printer->print(mCount);
141 printer->println(F(
" test(s)."));
144 void TestRunner::setRunnerTimeout(TimeoutType timeout) {