From 02760eafc803dd47050e6e4e9d2b42d7d1850e3b Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 2 Nov 2018 12:53:19 +0100 Subject: [PATCH] LSP: Fix auto tests for Linux and macOS Some URI/URL functionality (especially file protocol) is based on the underlying file system and operating system respectively. Change-Id: I6a0956bbef292ff964aec581c2555c54d6d0dbe3 Reviewed-by: David Schulz --- .../tst_languageserverprotocol.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp b/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp index 3a7a83c7bfc..f4c94a36b94 100644 --- a/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp +++ b/tests/auto/languageserverprotocol/tst_languageserverprotocol.cpp @@ -598,7 +598,9 @@ void tst_LanguageServerProtocol::documentUri_data() QTest::addColumn("fileName"); QTest::addColumn("string"); - const QString filePrefix("file:///"); + // '/' (fs root) is part of the file path + const QString filePrefix = Utils::HostOsInfo::isWindowsHost() ? QString("file:///") + : QString("file://"); QTest::newRow("empty uri") << DocumentUri() @@ -613,7 +615,7 @@ void tst_LanguageServerProtocol::documentUri_data() << Utils::FileName::fromUserInput(QDir::homePath()) << QString(filePrefix + QDir::homePath()); - const QString argv0 = qApp->arguments().first(); + const QString argv0 = QFileInfo(qApp->arguments().first()).absoluteFilePath(); const auto argv0FileName = Utils::FileName::fromUserInput(argv0); QTest::newRow("argv0 file name") << DocumentUri::fromFileName(argv0FileName) @@ -627,8 +629,10 @@ void tst_LanguageServerProtocol::documentUri_data() << Utils::FileName() << "https://www.qt.io/"; + // depending on the OS the resulting path is different (made suitable for the file system) const QString winUserPercent("file:///C%3A/Users/"); - const QString winUser("C:\\Users\\"); + const QString winUser = Utils::HostOsInfo::isWindowsHost() ? QString("C:\\Users\\") + : QString("/C:/Users/"); QTest::newRow("percent encoding") << DocumentUri::fromProtocol(winUserPercent) << true