diff options
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/doc/qttestlib.qdocconf | 2 | ||||
-rw-r--r-- | src/testlib/doc/src/qttestlib-manual.qdoc | 5 | ||||
-rw-r--r-- | src/testlib/qtest.h | 2 | ||||
-rw-r--r-- | src/testlib/qtestblacklist.cpp | 70 | ||||
-rw-r--r-- | src/testlib/qtestcase.cpp | 2 |
5 files changed, 57 insertions, 24 deletions
diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf index 0fafc733b1..899f94ec53 100644 --- a/src/testlib/doc/qttestlib.qdocconf +++ b/src/testlib/doc/qttestlib.qdocconf @@ -4,7 +4,7 @@ project = QtTestLib description = Qt Test Reference Documentation version = $QT_VERSION -examplesinstallpath = testlib +examplesinstallpath = qtestlib qhp.projects = QtTestLib diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index 62cc6c9654..fc8f3b747e 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -487,6 +487,7 @@ \nextpage {Chapter 2: Data Driven Testing}{Chapter 2} \title Chapter 1: Writing a Unit Test + \brief How to write a unit test. In this first chapter we will see how to write a simple unit test for a class, and how to execute it. @@ -562,6 +563,7 @@ \nextpage {Chapter 3: Simulating Gui Events}{Chapter 3} \title Chapter 2: Data Driven Testing + \brief How to create data driven tests. In this chapter we will demonstrate how to execute a test multiple times with different test data. @@ -667,6 +669,7 @@ \nextpage {Chapter 4: Replaying GUI Events}{Chapter 4} \title Chapter 3: Simulating GUI Events + \brief Howe to simulate GUI events. Qt Test features some mechanisms to test graphical user interfaces. Instead of simulating native window system events, @@ -727,6 +730,7 @@ \nextpage {Chapter 5: Writing a Benchmark}{Chapter 5} \title Chapter 4: Replaying GUI Events + \brief How to replay GUI events. In this chapter, we will show how to simulate a GUI event, and how to store a series of GUI events as well as replay them on @@ -806,6 +810,7 @@ \contentspage {Qt Test Tutorial}{Contents} \title Chapter 5: Writing a Benchmark + \brief How to write a benchmark. In this final chapter we will demonstrate how to write benchmarks using Qt Test. diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 261c769c15..49a0c2104b 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -160,7 +160,7 @@ template<> inline char *toString(const QVariant &v) if (!v.isNull()) { vstring.append(','); if (v.canConvert(QVariant::String)) { - vstring.append(qvariant_cast<QString>(v).toLocal8Bit()); + vstring.append(v.toString().toLocal8Bit()); } else { vstring.append("<value not representable as string>"); diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp index 4435b509be..1fa76a692a 100644 --- a/src/testlib/qtestblacklist.cpp +++ b/src/testlib/qtestblacklist.cpp @@ -52,21 +52,38 @@ QT_BEGIN_NAMESPACE /* - The file format is simply a grouped listing of keywords - Ungrouped entries at the beginning apply to the whole testcase - Groups define testfunctions or specific test data to ignore. - After the groups come a list of entries (one per line) that define - for which platform/os combination to ignore the test result. - All keys in a single line have to match to blacklist the test. - - mac - [testFunction] - linux - windows 64bit - [testfunction2:testData] - msvc - - The known keys are listed below: + The BLACKLIST file format is a grouped listing of keywords. + + Blank lines and lines starting with # are simply ignored. An initial #-line + referring to this documentation is kind to readers. Comments can also be used + to indicate the reasons for ignoring particular cases. + + A key names a platform, O/S, distribution, tool-chain or architecture; a ! + prefix reverses what it checks. A version, joined to a key (at present, only + for distributions and for msvc) with a hyphen, limits the key to the specific + version. A keyword line matches if every key on it applies to the present + run. Successive lines are alternate conditions for ignoring a test. + + Ungrouped lines at the beginning of a file apply to the whole testcase. + A group starts with a [square-bracketed] identification of a test function, + optionally with (after a colon, the name of) a specific data set, to ignore. + Subsequent lines give conditions for ignoring this test. + + # See qtbase/src/testlib/qtestblacklist.cpp for format + osx + + # QTBUG-12345 + [testFunction] + linux + windows 64bit + + # Needs basic C++11 support + [testfunction2:testData] + msvc-2010 + + Keys are lower-case. Distribution name and version are supported if + QSysInfo's productType() and productVersion() return them. + The other known keys are listed below: */ static QSet<QByteArray> keywords() @@ -148,19 +165,30 @@ static QSet<QByteArray> keywords() return set; } -static bool checkCondition(const QByteArray &condition) +static QSet<QByteArray> activeConditions() { - static QSet<QByteArray> matchedConditions = keywords(); - QList<QByteArray> conds = condition.split(' '); + QSet<QByteArray> result = keywords(); QByteArray distributionName = QSysInfo::productType().toLower().toUtf8(); QByteArray distributionRelease = QSysInfo::productVersion().toLower().toUtf8(); if (!distributionName.isEmpty()) { - if (matchedConditions.find(distributionName) == matchedConditions.end()) - matchedConditions.insert(distributionName); - matchedConditions.insert(distributionName + "-" + distributionRelease); + if (result.find(distributionName) == result.end()) + result.insert(distributionName); + if (!distributionRelease.isEmpty()) { + QByteArray versioned = distributionName + "-" + distributionRelease; + if (result.find(versioned) == result.end()) + result.insert(versioned); + } } + return result; +} + +static bool checkCondition(const QByteArray &condition) +{ + static const QSet<QByteArray> matchedConditions = activeConditions(); + QList<QByteArray> conds = condition.split(' '); + for (int i = 0; i < conds.size(); ++i) { QByteArray c = conds.at(i); bool result = c.startsWith('!'); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 73303ca28d..b6c70fdd86 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -116,7 +116,7 @@ static bool debuggerPresent() if (fd == -1) return false; char buffer[2048]; - ssize_t size = read(fd, buffer, sizeof(buffer)); + ssize_t size = read(fd, buffer, sizeof(buffer) - 1); if (size == -1) { close(fd); return false; |