Fix QDirIterator benchmark to actually find its test data
The benchmark had a hard-coded path on MS and needed an environment variable set otherwise; neither sounds like a good approach, when testlib defines a variable that tells us the test's source directory, a clearly superior way to find things in our source directories. In the process, replace exit()ing on failure to get a path with a QSKIP() so that the test at least fails gracefully if it ever can't find its data. (Using QFAIL() left it with no rows but still trying to run the test, leading to an assert failure.) Task-number: QTBUG-91713 Change-Id: I1bd5561971239bb838bcf6c24bcdf1d07c81a657 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 74e9b77f4f3bd823d836a2a1a557b294582bac5e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
dc70e511a8
commit
4030fb4292
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the test suite of the Qt Toolkit.
|
** This file is part of the test suite of the Qt Toolkit.
|
||||||
@ -64,24 +64,22 @@ private slots:
|
|||||||
void stdRecursiveDirectoryIterator_data() { data(); }
|
void stdRecursiveDirectoryIterator_data() { data(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void tst_qdiriterator::data()
|
void tst_qdiriterator::data()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
const char hereRelative[] = "tests/benchmarks/corelib/io/qdiriterator";
|
||||||
const char *qtdir = "C:\\depot\\qt\\main";
|
QByteArray dir(QT_TESTCASE_SOURCEDIR);
|
||||||
#else
|
// qDebug("Source dir: %s", dir.constData());
|
||||||
const char *qtdir = ::getenv("QTDIR");
|
dir.chop(sizeof(hereRelative)); // Counts the '\0', making up for the omitted leading '/'
|
||||||
#endif
|
// qDebug("Root dir: %s", dir.constData());
|
||||||
if (!qtdir) {
|
|
||||||
fprintf(stderr, "QTDIR not set\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTest::addColumn<QByteArray>("dirpath");
|
QTest::addColumn<QByteArray>("dirpath");
|
||||||
QByteArray ba = QByteArray(qtdir) + "/src/corelib";
|
const QByteArray ba = dir + "/src/corelib";
|
||||||
QByteArray ba1 = ba + "/io";
|
|
||||||
QTest::newRow(ba) << ba;
|
if (!QFileInfo(QString::fromLocal8Bit(ba)).isDir())
|
||||||
//QTest::newRow(ba1) << ba1;
|
QSKIP("Missing Qt directory");
|
||||||
|
|
||||||
|
QTest::newRow("corelib") << ba;
|
||||||
|
QTest::newRow("corelib/io") << (ba + "/io");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user