aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/tools
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-08-22 04:02:09 -0700
committerJake Petroules <jake.petroules@qt.io>2017-08-23 18:29:31 +0000
commit5148ed8889674aba61f11e2fa0a7796a5869fb11 (patch)
tree1796b4c8f8f1f665a75f572a9f77c63f9e43bd44 /tests/auto/tools
parent29ff75ef89d93934bdbc38e24398e766e6597508 (diff)
Fix problems with drive root paths on Windows
This patch ensures that paths are correctly resolved against drive roots on Windows, for example, resolvePath("C:\\foo", "..") now results in "C:\\" rather than "C:" which is actually a relative path. It also fixes a related issue in the product installer where one character may have been truncated from the middle of a path since the (absolute) prefix was always assumed to NOT end with a slash, which is always canonical on Unix but not necessarily on Windows in the case of drive roots where a trailing slash is necessary to differentiate from relative path of the current drive. Change-Id: I6c5ab1de517bb6933c3b4aebdd22236bb71c1d37 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto/tools')
-rw-r--r--tests/auto/tools/tst_tools.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp
index 13bc18b36..0ee7b18ab 100644
--- a/tests/auto/tools/tst_tools.cpp
+++ b/tests/auto/tools/tst_tools.cpp
@@ -87,12 +87,21 @@ void TestTools::testFileInfo()
QCOMPARE(FileInfo::path("C:/fileInDriveRoot"), QString("C:/"));
QVERIFY(!FileInfo::isAbsolute("bla/lol"));
QVERIFY(FileInfo::isAbsolute("/bla/lol"));
- if (HostOsInfo::isWindowsHost())
+ if (HostOsInfo::isWindowsHost()) {
QVERIFY(FileInfo::isAbsolute("C:\\bla\\lol"));
+ QVERIFY(FileInfo::isAbsolute("C:\\"));
+ QVERIFY(FileInfo::isAbsolute("C:/"));
+ QVERIFY(!FileInfo::isAbsolute("C:"));
+ }
QCOMPARE(FileInfo::resolvePath("/abc/lol", "waffl"), QString("/abc/lol/waffl"));
QCOMPARE(FileInfo::resolvePath("/abc/def/ghi/jkl/", "../foo/bar"), QString("/abc/def/ghi/foo/bar"));
QCOMPARE(FileInfo::resolvePath("/abc/def/ghi/jkl/", "../../foo/bar"), QString("/abc/def/foo/bar"));
QCOMPARE(FileInfo::resolvePath("/abc", "../../../foo/bar"), QString("/foo/bar"));
+ if (HostOsInfo::isWindowsHost()) {
+ QCOMPARE(FileInfo::resolvePath("C:/share", ".."), QString("C:/"));
+ QCOMPARE(FileInfo::resolvePath("C:/share", "D:/"), QString("D:/"));
+ QCOMPARE(FileInfo::resolvePath("C:/share", "D:"), QString()); // should soft-assert
+ }
QCOMPARE(FileInfo("/does/not/exist").lastModified(), FileTime());
}