diff options
author | Caroline Chao <caroline.chao@nokia.com> | 2012-02-02 10:12:21 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-12 23:25:19 +0100 |
commit | a6d3983ef6b7affef1d2aa48ed8bf8000a6e4267 (patch) | |
tree | 1122d85d2bfed7e2665b500b0e41871bfdeb79d2 /src/testlib/qtestlog.cpp | |
parent | 3aacbc1e2bea0855f5a405be0e1577320af784f7 (diff) |
CodeCoverage: Handle QTest based subtests.
Set QT_TESTCOCOON_ACTIVE environment variable when the coverage is installed
for a test and unset it when the coverage data is saved. Tests that run when
QT_TESTCOCOON_ACTIVE is set are subtests and will not be considered as
stand-alone tests for the coverage.
When a test is run as a subtest its coverage data will not be saved for
itself but for the main test it is merged with. Also its status will not be
reported since only the status of the main test is expected in the test report,
e.g. the test tests/auto/testlib/selftests.
Change-Id: Icfdf99300aae18040e1a3441a8af21f68df4c0db
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'src/testlib/qtestlog.cpp')
-rw-r--r-- | src/testlib/qtestlog.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 29dfbc144e..c8487a2c54 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -56,9 +56,11 @@ QT_BEGIN_NAMESPACE -static void saveCoverageTool(const char * appname, bool testfailed) +static void saveCoverageTool(const char * appname, bool testfailed, bool installedTestCoverage) { #ifdef __COVERAGESCANNER__ + if (!installedTestCoverage) + return; // install again to make sure the filename is correct. // without this, a plugin or similar may have changed the filename. __coveragescanner_install(appname); @@ -66,9 +68,11 @@ static void saveCoverageTool(const char * appname, bool testfailed) __coveragescanner_save(); __coveragescanner_testname(""); __coveragescanner_clear(); + unsetenv("QT_TESTCOCOON_ACTIVE"); #else Q_UNUSED(appname); Q_UNUSED(testfailed); + Q_UNUSED(installedTestCoverage); #endif } @@ -198,6 +202,7 @@ namespace QTest { static int verbosity = 0; static int maxWarnings = 2002; + static bool installedTestCoverage = true; static QtMsgHandler oldMessageHandler; @@ -388,7 +393,7 @@ void QTestLog::stopLogging() QTest::TestLoggers::stopLogging(); QTest::TestLoggers::destroyLoggers(); QTest::loggerUsingStdout = false; - saveCoverageTool(QTestResult::currentAppname(), failCount() != 0); + saveCoverageTool(QTestResult::currentAppname(), failCount() != 0, QTestLog::installedTestCoverage()); } void QTestLog::addLogger(LogMode mode, const char *filename) @@ -502,4 +507,14 @@ void QTestLog::resetCounters() QTest::skips = 0; } +void QTestLog::setInstalledTestCoverage(bool installed) +{ + QTest::installedTestCoverage = installed; +} + +bool QTestLog::installedTestCoverage() +{ + return QTest::installedTestCoverage; +} + QT_END_NAMESPACE |