summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-02-15 17:00:10 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-03-14 20:16:35 +0100
commit479c95729a986fb9a6a25cdf763898cb865b61c7 (patch)
treeeba45187e69fb6908050cf78b7399cda73aeb20e /src/testlib/qtestcase.cpp
parentf081b2cb37e94fbf2e81013aa61da593fcba81c9 (diff)
Support global data tags in blacklisting identification of test-cases
Previously the blacklisting file format only worked with slot:data or plain slot names for the items to blacklist. However, tests with global data report themselves with the global data-row tag in the same way as function-specific ones do; and tests which have both join the two as slot(global:data) in the test output name, so the reader is apt to mistake global:data for a data tag. In any case, it is potentially desirable to be able to blacklist a function with either or both of global and local data-row tags specified. Add support for that and remove a blacklisting that was only needed due to the lack of this support. For now, make the new parameter to checkBlackLists() optional, so that qtdeclarative's qmltest framework can adapt to this change. Fixes: QTBUG-100870 Change-Id: I9125811ebdab75d3fb462ba8b60561f003426502 Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 5176c03931..a773d7b0e1 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1164,6 +1164,9 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
const QTestTable *gTable = QTestTable::globalTestTable();
const int globalDataCount = gTable->dataCount();
int curGlobalDataIndex = 0;
+ const auto globalDataTag = [gTable, globalDataCount](int index) {
+ return globalDataCount ? gTable->testData(index)->dataTag() : nullptr;
+ };
/* For each entry in the global data table, do: */
do {
@@ -1180,6 +1183,9 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
bool foundFunction = false;
int curDataIndex = 0;
const int dataCount = table.dataCount();
+ const auto dataTag = [&table, dataCount](int index) {
+ return dataCount ? table.testData(index)->dataTag() : nullptr;
+ };
// Data tag requested but none available?
if (data && !dataCount) {
@@ -1200,7 +1206,8 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) {
foundFunction = true;
- QTestPrivate::checkBlackLists(name.constData(), dataCount ? table.testData(curDataIndex)->dataTag() : nullptr);
+ QTestPrivate::checkBlackLists(name.constData(), dataTag(curDataIndex),
+ globalDataTag(curGlobalDataIndex));
QTestDataSetter s(curDataIndex >= dataCount ? nullptr : table.testData(curDataIndex));