make stubs for dangerous/useless qmake functions in limited mode
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Thu, 16 May 2013 13:21:20 +0000 (15:21 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 21 May 2013 12:43:21 +0000 (14:43 +0200)
instead of having them "not implemented" (and consequently getting
errors), just let requires(), system(), mkpath(), write_file(), touch()
and cache() do nothing. this is likely to cause followup failures which
are harder to detect, but the amount of scary noise we are producing now
is not really acceptable. furthermore, in qtcreator these failures
actually terminate the "precise" evaluation, which breaks Run
Configurations.

Task-number: QTBUG-28159
Task-number: QTCREATORBUG-8550 (in different repo)
Change-Id: I1bdeb759e895e4200f09332dadf8a6cef348182f
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
src/linguist/shared/qmakebuiltins.cpp
tests/auto/linguist/lupdate/tst_lupdate.cpp

index a7a0ee7..b2132c3 100644 (file)
@@ -1117,11 +1117,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
             }
         }
         return ReturnFalse;
-#ifdef PROEVALUATOR_FULL
     case T_REQUIRES:
+#ifdef PROEVALUATOR_FULL
         checkRequirements(args);
-        return ReturnFalse; // Another qmake breakage
 #endif
+        return ReturnFalse; // Another qmake breakage
     case T_EVAL: {
             VisitReturn ret = ReturnFalse;
             ProFile *pro = m_parser->parsedProBlock(args.join(statics.field_sep),
@@ -1383,14 +1383,14 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
         }
         return (func_t == T_ERROR && !m_cumulative) ? ReturnError : ReturnTrue;
     }
-#ifdef PROEVALUATOR_FULL
     case T_SYSTEM: {
-        if (m_cumulative) // Anything else would be insanity
-            return ReturnFalse;
         if (args.count() != 1) {
             evalError(fL1S("system(exec) requires one argument."));
             return ReturnFalse;
         }
+#ifdef PROEVALUATOR_FULL
+        if (m_cumulative) // Anything else would be insanity
+            return ReturnFalse;
 #ifndef QT_BOOTSTRAPPED
         QProcess proc;
         proc.setProcessChannelMode(QProcess::ForwardedChannels);
@@ -1401,8 +1401,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
                                   + IoUtils::shellQuote(QDir::toNativeSeparators(currentDirectory()))
                                   + QLatin1String(" && ") + args.at(0)).toLocal8Bit().constData()) == 0);
 #endif
-    }
+#else
+        return ReturnTrue;
 #endif
+    }
     case T_ISEMPTY: {
         if (args.count() != 1) {
             evalError(fL1S("isEmpty(var) requires one argument."));
@@ -1429,17 +1431,18 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
 
         return ReturnFalse;
     }
-#ifdef PROEVALUATOR_FULL
     case T_MKPATH: {
         if (args.count() != 1) {
             evalError(fL1S("mkpath(file) requires one argument."));
             return ReturnFalse;
         }
+#ifdef PROEVALUATOR_FULL
         const QString &fn = resolvePath(args.at(0).toQString(m_tmp1));
         if (!QDir::current().mkpath(fn)) {
             evalError(fL1S("Cannot create directory %1.").arg(QDir::toNativeSeparators(fn)));
             return ReturnFalse;
         }
+#endif
         return ReturnTrue;
     }
     case T_WRITE_FILE: {
@@ -1447,6 +1450,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
             evalError(fL1S("write_file(name, [content var, [append]]) requires one to three arguments."));
             return ReturnFalse;
         }
+#ifdef PROEVALUATOR_FULL
         QIODevice::OpenMode mode = QIODevice::Truncate;
         QString contents;
         if (args.count() >= 2) {
@@ -1458,12 +1462,16 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
                     mode = QIODevice::Append;
         }
         return writeFile(QString(), resolvePath(args.at(0).toQString(m_tmp1)), mode, contents);
+#else
+        return ReturnTrue;
+#endif
     }
     case T_TOUCH: {
         if (args.count() != 2) {
             evalError(fL1S("touch(file, reffile) requires two arguments."));
             return ReturnFalse;
         }
+#ifdef PROEVALUATOR_FULL
         const QString &tfn = resolvePath(args.at(0).toQString(m_tmp1));
         const QString &rfn = resolvePath(args.at(1).toQString(m_tmp2));
 #ifdef Q_OS_UNIX
@@ -1500,6 +1508,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
         SetFileTime(wHand, 0, 0, &ft);
         CloseHandle(wHand);
 #endif
+#endif
         return ReturnTrue;
     }
     case T_CACHE: {
@@ -1507,6 +1516,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
             evalError(fL1S("cache(var, [set|add|sub] [transient] [super], [srcvar]) requires one to three arguments."));
             return ReturnFalse;
         }
+#ifdef PROEVALUATOR_FULL
         bool persist = true;
         bool super = false;
         enum { CacheSet, CacheAdd, CacheSub } mode = CacheSet;
@@ -1632,8 +1642,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
             fn = m_cachefile;
         }
         return writeFile(fL1S("cache "), fn, QIODevice::Append, varstr);
-    }
+#else
+        return ReturnTrue;
 #endif
+    }
     default:
         evalError(fL1S("Function '%1' is not implemented.").arg(function.toQString(m_tmp1)));
         return ReturnFalse;
index 3413380..2e68383 100644 (file)
@@ -122,19 +122,12 @@ static bool prepareMatch(const QString &expect, QString *tmpl, int *require, int
     return true;
 }
 
-void tst_lupdate::doCompare(const QStringList &_actual, const QString &expectedFn, bool err)
+void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn, bool err)
 {
     QFile file(expectedFn);
     QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(expectedFn));
     QStringList expected = QString(file.readAll()).split('\n');
 
-    QStringList actual;
-    actual.reserve(_actual.size());
-    QRegExp niRx(".*:(Function '\\w+' is not implemented|'\\w+' is not a recognized replace function)");
-    foreach (const QString &a, _actual)
-        if (!niRx.exactMatch(a))
-            actual << a;
-
     int ei = 0, ai = 0, em = expected.size(), am = actual.size();
     int oei = 0, oai = 0, oem = em, oam = am;
     int require = 0, accept = 0;