From c7748b7838522ec38ec01423f1267acf1f163606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 9 Mar 2011 19:46:08 +0100 Subject: QDir: Fix absolute paths when using file engines QFileSystemEntry doesn't know about paths as implemented by custom file engines, such as is the case with resource files. In such cases, we need to allow the engine to make the relative to absolute conversion. Expanded QDir's test case to ensure resource paths are considered in more places. Task-number: QTBUG-17921 Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 15 +++++++++++---- tests/auto/qdir/tst_qdir.cpp | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 42f1652..166513a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -196,12 +196,19 @@ inline void QDirPrivate::resolveAbsoluteEntry() const if (!absoluteDirEntry.isEmpty() || dirEntry.isEmpty()) return; - if (dirEntry.isRelative()) { - QFileSystemEntry answer = QFileSystemEngine::absoluteName(dirEntry); - absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(answer.filePath()), QFileSystemEntry::FromInternalPath()); + QString absoluteName; + if (fileEngine.isNull()) { + if (!dirEntry.isRelative()) { + absoluteDirEntry = dirEntry; + return; + } + + absoluteName = QFileSystemEngine::absoluteName(dirEntry).filePath(); } else { - absoluteDirEntry = dirEntry; + absoluteName = fileEngine->fileName(QAbstractFileEngine::AbsoluteName); } + + absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(absoluteName), QFileSystemEntry::FromInternalPath()); } /* For sorting */ diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 2fa0c24..04f7fa9 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -420,6 +420,9 @@ void tst_QDir::isRelativePath_data() #endif QTest::newRow("data2") << "somedir" << true; QTest::newRow("data3") << "/somedir" << false; + + QTest::newRow("resource0") << ":/prefix" << false; + QTest::newRow("resource1") << ":/prefix/foo.bar" << false; } void tst_QDir::isRelativePath() @@ -868,6 +871,8 @@ void tst_QDir::canonicalPath_data() QTest::newRow("drive:\\..\\..") << QDir::toNativeSeparators(QDir::rootPath().append("../..")) << QDir::rootPath(); QTest::newRow("drive:") << QDir().canonicalPath().left(2) << QDir().canonicalPath(); #endif + + QTest::newRow("resource") << ":/tst_qdir/resources/entryList" << ":/tst_qdir/resources/entryList"; } void tst_QDir::canonicalPath() @@ -1061,6 +1066,9 @@ tst_QDir::cleanPath_data() QTest::newRow("data10") << "/:/" << "/:"; #endif #endif + + QTest::newRow("resource0") << ":/prefix/foo.bar" << ":/prefix/foo.bar"; + QTest::newRow("resource1") << "://prefix/..//prefix/foo.bar" << ":/prefix/foo.bar"; } @@ -1084,6 +1092,7 @@ void tst_QDir::absoluteFilePath_data() QTest::newRow("2") << "/" << "passwd" << "/passwd"; QTest::newRow("3") << "relative" << "path" << QDir::currentPath() + "/relative/path"; QTest::newRow("4") << "" << "" << QDir::currentPath(); + QTest::newRow("resource") << ":/prefix" << "foo.bar" << ":/prefix/foo.bar"; } void tst_QDir::absoluteFilePath() @@ -1112,6 +1121,7 @@ void tst_QDir::absolutePath_data() QTest::newRow("4") << "c:/machine/share/dir1" << "c:/machine/share/dir1"; QTest::newRow("5") << "c:\\machine\\share\\dir1" << "c:/machine/share/dir1"; #endif + QTest::newRow("resource") << ":/prefix/foo.bar" << ":/prefix/foo.bar"; } void tst_QDir::absolutePath() @@ -1171,6 +1181,9 @@ void tst_QDir::relativeFilePath_data() QTest::newRow("33") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar"; # endif #endif + + QTest::newRow("resource0") << ":/prefix" << "foo.bar" << "foo.bar"; + QTest::newRow("resource1") << ":/prefix" << ":/prefix/foo.bar" << "foo.bar"; } void tst_QDir::relativeFilePath() @@ -1193,6 +1206,7 @@ void tst_QDir::filePath_data() QTest::newRow("2") << "/" << "passwd" << "/passwd"; QTest::newRow("3") << "relative" << "path" << "relative/path"; QTest::newRow("4") << "" << "" << "."; + QTest::newRow("resource") << ":/prefix" << "foo.bar" << ":/prefix/foo.bar"; } void tst_QDir::filePath() @@ -1255,6 +1269,8 @@ void tst_QDir::exists2_data() QTest::newRow("4") << "/testData" << false; QTest::newRow("5") << "tst_qdir.cpp" << true; QTest::newRow("6") << "/resources.cpp" << false; + QTest::newRow("resource0") << ":/prefix/foo.bar" << false; + QTest::newRow("resource1") << ":/tst_qdir/resources/entryList/file1.data" << true; } void tst_QDir::exists2() @@ -1291,6 +1307,8 @@ void tst_QDir::dirName_data() QTest::newRow("bslash1") << "\\winnt\\system32" << "system32"; QTest::newRow("bslash2") << "c:\\winnt\\system32\\kernel32.dll" << "kernel32.dll"; #endif + + QTest::newRow("resource") << ":/prefix" << "prefix"; } void tst_QDir::dirName() @@ -1961,6 +1979,8 @@ void tst_QDir::isRelative_data() foreach (QFileInfo root, QDir::drives()) { QTest::newRow(root.absolutePath().toLocal8Bit()) << root.absolutePath() << false; } + + QTest::newRow("resource") << ":/prefix" << false; } void tst_QDir::isRelative() -- cgit v0.12 From 07f975eef127048b8150b368259afcad183e6424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 25 Mar 2011 12:30:33 +0100 Subject: Skip failing tests c7748b7838522ec38ec01423f1267acf1f163606 fixed a bug in QDir::absoluteFilePath that was masking failures in QtScript's v8 test suite. Those will have to be looked into separately. For now, skipping the tests. These are the uncovered failures, broken out by platform and test, and formatted as "test-name:line-number: actual-value / expected-value": * linux-icc_ubuntu1004 - math-min-max:50: Inf / -Inf - negate-zero:50: false / true - str-to-num:50: Inf / -Inf * linux-icc_ubuntu1004 & macx-g++_cocoa_osx106 - smi-negative-zero:50: -Inf / Inf * linux-icc_ubuntu1004 & macx-g++_cocoa & macx-g++_cocoa_osx106 & win32-msvc2005_windows_xp & win32-msvc2008_windows_xp - to-precision:50: 1.235e+27 / 1.234e+27 Reviewed-by: Kent Hansen --- tests/auto/qscriptv8testsuite/abstracttestsuite.cpp | 12 ++++++++++++ tests/auto/qscriptv8testsuite/skip.txt | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp b/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp index d47eb24..0978293 100644 --- a/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp +++ b/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp @@ -276,8 +276,11 @@ bool TestConfigParser::isKnownSymbol(const QString &symbol) << "Q_OS_SOLARIS" << "Q_OS_WINCE" << "Q_OS_SYMBIAN" + << "Q_OS_MAC" + << "Q_OS_WIN" << "Q_CC_MSVC" << "Q_CC_MINGW" + << "Q_CC_INTEL" ; } return knownSymbols.contains(symbol); @@ -299,12 +302,21 @@ bool TestConfigParser::isDefined(const QString &symbol) #ifdef Q_OS_SYMBIAN << "Q_OS_SYMBIAN" #endif +#ifdef Q_OS_MAC + << "Q_OS_MAC" +#endif +#ifdef Q_OS_WIN + << "Q_OS_WIN" +#endif #ifdef Q_CC_MSVC << "Q_CC_MSVC" #endif #ifdef Q_CC_MINGW << "Q_CC_MINGW" #endif +#ifdef Q_CC_INTEL + << "Q_CC_INTEL" +#endif ; } return definedSymbols.contains(symbol); diff --git a/tests/auto/qscriptv8testsuite/skip.txt b/tests/auto/qscriptv8testsuite/skip.txt index 3c2cc53..9658c2b 100644 --- a/tests/auto/qscriptv8testsuite/skip.txt +++ b/tests/auto/qscriptv8testsuite/skip.txt @@ -15,3 +15,17 @@ mul-exhaustive | Demands too much memory on WinCE [Q_OS_SYMBIAN] nested-repetition-count-overflow | Demands too much memory on Symbian unicode-test | Demands too much memory on Symbian + +[Q_CC_INTEL] +math-min-max | Unresolved failures with intel compiler +negate-zero | Unresolved failures with intel compiler +smi-negative-zero | Unresolved failures with intel compiler +str-to-num | Unresolved failures with intel compiler +to-precision | Unresolved failures with intel compiler + +[Q_OS_MAC] +smi-negative-zero | Unresolved failures on Mac OS X (Cocoa) +to-precision | Unresolved failures on Mac OS X (Cocoa) + +[Q_OS_WIN] +to-precision | Unresolved failures on Windows -- cgit v0.12