Skip tests if the required plugins were not deployed

This is usually the case on Android, where running this test would
require deployment of files to the emulator. This doesn't give us any
further testing that we don't already do by running this test on regular
Linux, so skipping the test instead if the preconditions aren't met.

Change-Id: I3722796634871213ba51c89ae7f40b19f954f2cb
Fixes: QTBUG-73566
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Volker Hilsheimer 2019-06-19 16:50:48 +02:00
parent 64033c3592
commit 7f69c13fd9

View File

@ -41,7 +41,6 @@ class tst_QPlugin : public QObject
Q_OBJECT
QDir dir;
QString invalidPluginName;
public:
tst_QPlugin();
@ -64,15 +63,14 @@ void tst_QPlugin::initTestCase()
QVERIFY2(dir.exists(),
qPrintable(QString::fromLatin1("Cannot find the 'plugins' directory starting from '%1'").
arg(QDir::toNativeSeparators(QDir::currentPath()))));
const auto fileNames = dir.entryList({"*invalid*"}, QDir::Files);
if (!fileNames.isEmpty())
invalidPluginName = dir.absoluteFilePath(fileNames.first());
}
void tst_QPlugin::loadDebugPlugin()
{
const auto fileNames = dir.entryList(QStringList() << "*debug*", QDir::Files);
if (fileNames.isEmpty())
QSKIP("No debug plugins found - skipping test");
for (const QString &fileName : fileNames) {
if (!QLibrary::isLibrary(fileName))
continue;
@ -100,6 +98,9 @@ void tst_QPlugin::loadDebugPlugin()
void tst_QPlugin::loadReleasePlugin()
{
const auto fileNames = dir.entryList(QStringList() << "*release*", QDir::Files);
if (fileNames.isEmpty())
QSKIP("No release plugins found - skipping test");
for (const QString &fileName : fileNames) {
if (!QLibrary::isLibrary(fileName))
continue;
@ -227,7 +228,13 @@ static qsizetype locateMetadata(const uchar *data, qsizetype len)
void tst_QPlugin::scanInvalidPlugin()
{
QVERIFY(!invalidPluginName.isEmpty());
const auto fileNames = dir.entryList({"*invalid*"}, QDir::Files);
QString invalidPluginName;
if (fileNames.isEmpty())
QSKIP("No invalid plugin found - skipping test");
else
invalidPluginName = dir.absoluteFilePath(fileNames.first());
// copy the file
QFileInfo fn(invalidPluginName);