diff options
| author | Martin Hořeňovský | 2017-01-16 20:21:43 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2017-01-16 20:21:43 +0100 |
| commit | b71a06cf989bed309e4bdf84e2fff22850f9d47c (patch) | |
| tree | 3a01ad179c4004d550938327ac7fc41ea52e06ab /include | |
| parent | 531d26739fa35fa6737b21301acd2f002d99791f (diff) | |
| download | catch3-b71a06cf989bed309e4bdf84e2fff22850f9d47c.tar.gz | |
JUnit reporter outputs timestamps now
Also extended approval tests script to support the change
Diffstat (limited to 'include')
| -rw-r--r-- | include/reporters/catch_reporter_junit.hpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp index e656882f..6b2d6546 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -18,6 +18,35 @@ namespace Catch { + namespace { + std::string getCurrentTimestamp() { + // Beware, this is not reentrant because of backward compatibility issues + // Also, UTC only, again because of backward compatibility (%z is C++11) + time_t rawtime; + std::time(&rawtime); + const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z"); + +#ifdef CATCH_PLATFORM_WINDOWS + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &rawtime); +#else + std::tm* timeInfo; + timeInfo = std::gmtime(&rawtime); +#endif + + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef CATCH_PLATFORM_WINDOWS + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + + } + class JunitReporter : public CumulativeReporterBase { public: JunitReporter( ReporterConfig const& _config ) @@ -82,7 +111,7 @@ namespace Catch { xml.writeAttribute( "time", "" ); else xml.writeAttribute( "time", suiteTime ); - xml.writeAttribute( "timestamp", "tbd" ); // !TBD + xml.writeAttribute( "timestamp", getCurrentTimestamp() ); // Write test cases for( TestGroupNode::ChildNodes::const_iterator |