summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/qmakelib/evaltest.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-07-28 13:25:27 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2018-01-18 13:46:54 +0000
commite86f3c018833141776db2d15772ba53995656eac (patch)
tree2375bf7d4276968c783fe02e3d4482683937d194 /tests/auto/tools/qmakelib/evaltest.cpp
parent3149d0fb13bacc20b75ad8ca650c71df9edd8734 (diff)
qmake: require a drive in a DOS path for it to be absolute
For Q_OS_WIN, a path is only truly absolute if it includes a drive letter; merely starting with a slash is not enough. (We can't support UNC paths, so don't even try: qmake runs various commands in the source directory using CMD.exe, which doesn't support UNC as PWD.) This requires, when resolving a path relative to a root, transcribing the root's drive to such not-quite-absolute paths. Changed QMakeGlobals, $$absolute_path() and $$relative_path() to now use IoUtils::resolvePath() rather than delegating to QDir's absolute path method, since that doesn't correctly recognize the need for a drive letter (and qmake did run into problems with some paths, from splitPathList and a failing test, as a result). Moved existing ioUtils tests for handling of relative / absolute paths out into separate functions and expanded significantly. Fixed some existing tests to use an absolute path where one is needed; added two tests involving driveless (but rooted) paths; and fixed the test init to set a value for QT_HOST_DATA/src property (the lack of which lead to an assertion failure with this fix). Task-number: QTBUG-50839 Change-Id: I2bfc13c1bfbe1ae09997274622ea55cb3de31b43 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'tests/auto/tools/qmakelib/evaltest.cpp')
-rw-r--r--tests/auto/tools/qmakelib/evaltest.cpp46
1 files changed, 34 insertions, 12 deletions
diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp
index 03fd4753fd..cf69cc4026 100644
--- a/tests/auto/tools/qmakelib/evaltest.cpp
+++ b/tests/auto/tools/qmakelib/evaltest.cpp
@@ -34,6 +34,12 @@
#include <qmakeglobals.h>
#include <qmakeevaluator.h>
+#ifdef Q_OS_WIN
+# define EVAL_DRIVE "R:"
+#else
+# define EVAL_DRIVE
+#endif
+
void tst_qmakelib::addAssignments()
{
QTest::newRow("assignment")
@@ -1599,20 +1605,28 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< true;
QTest::newRow("$$absolute_path(): file & path")
- << "VAR = $$absolute_path(dir/file.ext, /root/sub)"
- << "VAR = /root/sub/dir/file.ext"
+ << "VAR = $$absolute_path(dir/file.ext, " EVAL_DRIVE "/root/sub)"
+ << "VAR = " EVAL_DRIVE "/root/sub/dir/file.ext"
<< ""
<< true;
+#ifdef Q_OS_WIN
+ QTest::newRow("$$absolute_path(): driveless file & absolute path")
+ << "VAR = $$absolute_path(/root/sub/dir/file.ext, " EVAL_DRIVE "/other)"
+ << "VAR = " EVAL_DRIVE "/root/sub/dir/file.ext"
+ << ""
+ << true;
+#endif
+
QTest::newRow("$$absolute_path(): absolute file & path")
- << "VAR = $$absolute_path(/root/sub/dir/file.ext, /other)"
- << "VAR = /root/sub/dir/file.ext"
+ << "VAR = $$absolute_path(" EVAL_DRIVE "/root/sub/dir/file.ext, " EVAL_DRIVE "/other)"
+ << "VAR = " EVAL_DRIVE "/root/sub/dir/file.ext"
<< ""
<< true;
QTest::newRow("$$absolute_path(): empty file & path")
- << "VAR = $$absolute_path('', /root/sub)"
- << "VAR = /root/sub"
+ << "VAR = $$absolute_path('', " EVAL_DRIVE "/root/sub)"
+ << "VAR = " EVAL_DRIVE "/root/sub"
<< ""
<< true;
@@ -1634,14 +1648,22 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< ""
<< true;
+#ifdef Q_OS_WIN
+ QTest::newRow("$$relative_path(): driveless file & absolute path")
+ << "VAR = $$relative_path(/root/sub/dir/file.ext, " EVAL_DRIVE "/root/sub)"
+ << "VAR = dir/file.ext"
+ << ""
+ << true;
+#endif
+
QTest::newRow("$$relative_path(): absolute file & path")
- << "VAR = $$relative_path(/root/sub/dir/file.ext, /root/sub)"
+ << "VAR = $$relative_path(" EVAL_DRIVE "/root/sub/dir/file.ext, " EVAL_DRIVE "/root/sub)"
<< "VAR = dir/file.ext"
<< ""
<< true;
QTest::newRow("$$relative_path(): empty file & path")
- << "VAR = $$relative_path('', /root/sub)"
+ << "VAR = $$relative_path('', " EVAL_DRIVE "/root/sub)"
<< "VAR = ."
<< ""
<< true;
@@ -2555,20 +2577,20 @@ void tst_qmakelib::addTestFunctions(const QString &qindir)
<< true;
QTest::newRow("touch(): missing target")
- << "touch(/does/not/exist, files/other.txt): OK = 1"
+ << "touch(" EVAL_DRIVE "/does/not/exist, files/other.txt): OK = 1"
<< "OK = UNDEF"
#ifdef Q_OS_WIN
- << "##:1: Cannot open /does/not/exist: The system cannot find the path specified."
+ << "##:1: Cannot open " EVAL_DRIVE "/does/not/exist: The system cannot find the path specified."
#else
<< "##:1: Cannot touch /does/not/exist: No such file or directory."
#endif
<< true;
QTest::newRow("touch(): missing reference")
- << "touch(" + wpath + ", /does/not/exist): OK = 1"
+ << "touch(" + wpath + ", " EVAL_DRIVE "/does/not/exist): OK = 1"
<< "OK = UNDEF"
#ifdef Q_OS_WIN
- << "##:1: Cannot open reference file /does/not/exist: The system cannot find the path specified."
+ << "##:1: Cannot open reference file " EVAL_DRIVE "/does/not/exist: The system cannot find the path specified."
#else
<< "##:1: Cannot stat() reference file /does/not/exist: No such file or directory."
#endif