mirror of https://github.com/catchorg/Catch2.git
JUnit reporter outputs timestamps now
Also extended approval tests script to support the change
This commit is contained in:
parent
531d26739f
commit
b71a06cf98
|
@ -18,6 +18,35 @@
|
||||||
|
|
||||||
namespace Catch {
|
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 {
|
class JunitReporter : public CumulativeReporterBase {
|
||||||
public:
|
public:
|
||||||
JunitReporter( ReporterConfig const& _config )
|
JunitReporter( ReporterConfig const& _config )
|
||||||
|
@ -82,7 +111,7 @@ namespace Catch {
|
||||||
xml.writeAttribute( "time", "" );
|
xml.writeAttribute( "time", "" );
|
||||||
else
|
else
|
||||||
xml.writeAttribute( "time", suiteTime );
|
xml.writeAttribute( "time", suiteTime );
|
||||||
xml.writeAttribute( "timestamp", "tbd" ); // !TBD
|
xml.writeAttribute( "timestamp", getCurrentTimestamp() );
|
||||||
|
|
||||||
// Write test cases
|
// Write test cases
|
||||||
for( TestGroupNode::ChildNodes::const_iterator
|
for( TestGroupNode::ChildNodes::const_iterator
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.1" encoding="UTF-8"?>
|
<?xml version="1.1" encoding="UTF-8"?>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="<exe-name>" errors="13" failures="68" tests="912" hostname="tbd" time="{duration}" timestamp="tbd">
|
<testsuite name="<exe-name>" errors="13" failures="68" tests="912" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||||
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
|
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
|
||||||
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
|
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
|
||||||
<failure message="false != false" type="CHECK">
|
<failure message="false != false" type="CHECK">
|
||||||
|
|
|
@ -16,6 +16,7 @@ pathParser = re.compile(r'(.*?)/(.*\..pp)(.*)')
|
||||||
lineNumberParser = re.compile(r'(.*)line="[0-9]*"(.*)')
|
lineNumberParser = re.compile(r'(.*)line="[0-9]*"(.*)')
|
||||||
hexParser = re.compile(r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)')
|
hexParser = re.compile(r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)')
|
||||||
durationsParser = re.compile(r'(.*)time="[0-9]*\.[0-9]*"(.*)')
|
durationsParser = re.compile(r'(.*)time="[0-9]*\.[0-9]*"(.*)')
|
||||||
|
timestampsParser = re.compile(r'(.*)timestamp="\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z"(.*)')
|
||||||
versionParser = re.compile(r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*(.*)')
|
versionParser = re.compile(r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*(.*)')
|
||||||
devVersionParser = re.compile(r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*-develop\.[0-9]*(.*)')
|
devVersionParser = re.compile(r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*-develop\.[0-9]*(.*)')
|
||||||
nullParser = re.compile(r'(.*?)\b(__null|nullptr)\b(.*)')
|
nullParser = re.compile(r'(.*?)\b(__null|nullptr)\b(.*)')
|
||||||
|
@ -73,6 +74,9 @@ def filterLine(line):
|
||||||
m = durationsParser.match(line)
|
m = durationsParser.match(line)
|
||||||
if m:
|
if m:
|
||||||
line = m.group(1) + 'time="{duration}"' + m.group(2)
|
line = m.group(1) + 'time="{duration}"' + m.group(2)
|
||||||
|
m = timestampsParser.match(line)
|
||||||
|
if m:
|
||||||
|
line = m.group(1) + 'timestamp="{iso8601-timestamp}"' + m.group(2)
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue