From 11ae4b70a164ee2d7d9894302b12574773a3e57b Mon Sep 17 00:00:00 2001 From: Amir Masoud Abdol Date: Thu, 9 Mar 2023 15:09:46 +0100 Subject: [PATCH] Fix tst_qfilesystementry in unity build Previous setup of the test was failing in minimal static build if built using the unity build because of the explicit inclusion of the qtcore source files. By removing them, it surfaced that QFileSystemEntry doesn't export all its necessary symbols for testing. So this patch does that, as well as removing the qtcore sources from the test. It also makes sense to make the test private. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Icdabe32485b7ce4ed6049bcc24918f531406b4bd Reviewed-by: Alexandru Croitor Reviewed-by: Joerg Bornemann --- src/corelib/io/qfilesystementry.cpp | 5 +++ src/corelib/io/qfilesystementry_p.h | 42 +++++++++---------- tests/auto/corelib/io/CMakeLists.txt | 2 +- .../io/qfilesystementry/CMakeLists.txt | 3 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index b507ad8ba02..6a655391be8 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -303,6 +303,11 @@ bool QFileSystemEntry::isRoot() const return isRootPath(m_filePath); } +bool QFileSystemEntry::isEmpty() const +{ + return m_filePath.isEmpty() && m_nativeFilePath.isEmpty(); +} + // private methods void QFileSystemEntry::findLastSeparator() const diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 049223fb911..8b5d506b0b2 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -33,36 +33,34 @@ public: struct FromNativePath{}; struct FromInternalPath{}; - QFileSystemEntry(); - explicit QFileSystemEntry(const QString &filePath); + Q_AUTOTEST_EXPORT QFileSystemEntry(); + Q_AUTOTEST_EXPORT explicit QFileSystemEntry(const QString &filePath); - QFileSystemEntry(const QString &filePath, FromInternalPath dummy); - QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath dummy); - QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath); + Q_AUTOTEST_EXPORT QFileSystemEntry(const QString &filePath, FromInternalPath dummy); + Q_AUTOTEST_EXPORT QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath dummy); + Q_AUTOTEST_EXPORT QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath); - QString filePath() const; - QString fileName() const; - QString path() const; - NativePath nativeFilePath() const; - QString baseName() const; - QString completeBaseName() const; - QString suffix() const; - QString completeSuffix() const; - bool isAbsolute() const; - bool isRelative() const; - bool isClean() const; + Q_AUTOTEST_EXPORT QString filePath() const; + Q_AUTOTEST_EXPORT QString fileName() const; + Q_AUTOTEST_EXPORT QString path() const; + Q_AUTOTEST_EXPORT NativePath nativeFilePath() const; + Q_AUTOTEST_EXPORT QString baseName() const; + Q_AUTOTEST_EXPORT QString completeBaseName() const; + Q_AUTOTEST_EXPORT QString suffix() const; + Q_AUTOTEST_EXPORT QString completeSuffix() const; + Q_AUTOTEST_EXPORT bool isAbsolute() const; + Q_AUTOTEST_EXPORT bool isRelative() const; + Q_AUTOTEST_EXPORT bool isClean() const; #if defined(Q_OS_WIN) - bool isDriveRoot() const; + Q_AUTOTEST_EXPORT bool isDriveRoot() const; static bool isDriveRootPath(const QString &path); static QString removeUncOrLongPathPrefix(QString path); #endif - bool isRoot() const; + Q_AUTOTEST_EXPORT bool isRoot() const; + + Q_AUTOTEST_EXPORT bool isEmpty() const; - bool isEmpty() const - { - return m_filePath.isEmpty() && m_nativeFilePath.isEmpty(); - } void clear() { *this = QFileSystemEntry(); diff --git a/tests/auto/corelib/io/CMakeLists.txt b/tests/auto/corelib/io/CMakeLists.txt index 880225bb891..4100ce17d56 100644 --- a/tests/auto/corelib/io/CMakeLists.txt +++ b/tests/auto/corelib/io/CMakeLists.txt @@ -42,7 +42,7 @@ if(NOT ANDROID) add_subdirectory(qdir) add_subdirectory(qresourceengine) endif() -if(QT_FEATURE_private_tests OR UNIX) +if(QT_FEATURE_private_tests) add_subdirectory(qfilesystementry) endif() # QTBUG-88508 diff --git a/tests/auto/corelib/io/qfilesystementry/CMakeLists.txt b/tests/auto/corelib/io/qfilesystementry/CMakeLists.txt index 47c5a38d651..570f457224d 100644 --- a/tests/auto/corelib/io/qfilesystementry/CMakeLists.txt +++ b/tests/auto/corelib/io/qfilesystementry/CMakeLists.txt @@ -7,9 +7,8 @@ qt_internal_add_test(tst_qfilesystementry SOURCES - ../../../../../src/corelib/io/qfilesystementry.cpp - ../../../../../src/corelib/io/qfilesystementry_p.h tst_qfilesystementry.cpp LIBRARIES Qt::CorePrivate + Qt::TestPrivate )