From 36f5cc848de25251bfb1cae2ddeea0871ded1fac Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 23 Jan 2012 12:55:21 +0100 Subject: CodeCoverage: Save coverage data in QTestLog::stopLogging() Currently when tests are crashing, aborting or hanging, their status are reported with a status "Unknown" because SaveCoverageTool is never called for them. The status of the test given by the coverage tool should be the same as the one reported in the log output when the test is run. This change will allow more accuracy in the status reported. Add QTestResult::setCurrentAppname and QTestResult::currentAppname. To retrieve the name of the current application running. Task-number: QTQAINFRA-460 Change-Id: Icc476dc2d6cb28185e5447f1e79da6a8a31cad54 Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- src/testlib/qtestlog.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/testlib/qtestlog.cpp') diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 7a4358a393..1d66101a0f 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -56,6 +56,22 @@ QT_BEGIN_NAMESPACE +static void saveCoverageTool(const char * appname, bool testfailed) +{ +#ifdef __COVERAGESCANNER__ + // install again to make sure the filename is correct. + // without this, a plugin or similar may have changed the filename. + __coveragescanner_install(appname); + __coveragescanner_teststate(testfailed ? "FAILED" : "PASSED"); + __coveragescanner_save(); + __coveragescanner_testname(""); + __coveragescanner_clear(); +#else + Q_UNUSED(appname); + Q_UNUSED(testfailed); +#endif +} + namespace QTest { int fails = 0; @@ -368,6 +384,7 @@ void QTestLog::stopLogging() QTest::TestLoggers::stopLogging(); QTest::TestLoggers::destroyLoggers(); QTest::loggerUsingStdout = false; + saveCoverageTool(QTestResult::currentAppname(), failCount() != 0); } void QTestLog::addLogger(LogMode mode, const char *filename) -- cgit v1.2.3