summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2024-03-17 12:51:38 +0200
committerAhmad Samir <a.samirh78@gmail.com>2024-03-19 15:52:48 +0200
commitb3e9e80719f5a69c8f28f6eceaadbbdd7f1f5fe5 (patch)
tree73c75e390d9cb269006e13fc6d743bc8fc247df9
parent14ec2ab89fa3347f95170d6980a6c793b7f37424 (diff)
tst_qdir: don't use the source dir for testing
Copy test dirs from the source dir to a QTemporaryDir, this way each run starts with a clean slate. Also on some setups the source dir could be read-only. Task-number: QTBUG-117449 Change-Id: Iea5fd661b66dd3cbae0b663bb504b14c8ccbe491 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 6e77a7c949..895f6e0998 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -207,12 +207,18 @@ private slots:
void stdfilesystem();
private:
-#ifdef BUILTIN_TESTDATA
- QString m_dataPath;
QSharedPointer<QTemporaryDir> m_dataDir;
-#else
- const QString m_dataPath;
-#endif
+ QString m_dataPath;
+
+ constexpr static const std::array m_testDirs = {
+ "entrylist"_L1,
+ "resources"_L1,
+ "searchdir"_L1,
+ "testData"_L1,
+ "testdir"_L1,
+ "types"_L1,
+ "tst_qdir.cpp"_L1,
+ };
};
Q_DECLARE_METATYPE(tst_QDir::UncHandling)
@@ -260,6 +266,20 @@ void tst_QDir::initTestCase()
m_dataDir = QEXTRACTTESTDATA("/");
QVERIFY2(!m_dataDir.isNull(), qPrintable("Did not find testdata. Is this builtin?"));
m_dataPath = m_dataDir->path();
+#elif QT_CONFIG(cxx17_filesystem) // This code doesn't work in QNX on the CI
+ m_dataDir.reset(new QTemporaryDir);
+ m_dataPath = m_dataDir->path();
+
+ QString sourceDir = QFileInfo(QFINDTESTDATA(m_testDirs[0])).absolutePath();
+ namespace fs = std::filesystem;
+ for (const auto &entry : m_testDirs) {
+ auto l1 = QLatin1StringView(entry);
+ const auto src = fs::path(QString(sourceDir + u'/' + l1).toStdString());
+ const auto dest = fs::path(QString(m_dataPath + u'/' + l1).toStdString());
+ std::error_code ec;
+ fs::copy(src, dest, fs::copy_options::recursive, ec);
+ QCOMPARE(ec.value(), 0);
+ }
#endif
QVERIFY2(!m_dataPath.isEmpty(), "test data not found");