print no message at all when no argument is supplied to error()

this is useful when an adequate message has already been emitted by
other means, like various built-ins do.

Change-Id: I092771f55969fad8b214204d666327664727c572
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Oswald Buddenhagen 2016-07-14 16:48:25 +02:00 committed by Lars Knoll
parent 6aa3ba0a0b
commit 22d1351dde
2 changed files with 8 additions and 2 deletions

View File

@ -1587,7 +1587,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
#ifdef PROEVALUATOR_FULL
fputs(msg.toLatin1().constData(), stderr);
#endif
} else {
} else if (!msg.isEmpty() || func_t != T_ERROR) {
m_handler->fileMessage(
(func_t == T_ERROR ? QMakeHandler::ErrorMessage :
func_t == T_WARNING ? QMakeHandler::WarningMessage :

View File

@ -2346,12 +2346,18 @@ void tst_qmakelib::addTestFunctions(const QString &qindir)
<< "Project WARNING: World, be warned!"
<< true;
QTest::newRow("error()")
QTest::newRow("error(message)")
<< "error('World, you FAIL!'): OK = 1\nOKE = 1"
<< "OK = UNDEF\nOKE = UNDEF"
<< "Project ERROR: World, you FAIL!"
<< false;
QTest::newRow("error(empty)")
<< "error(): OK = 1\nOKE = 1"
<< "OK = UNDEF\nOKE = UNDEF"
<< ""
<< false;
QTest::newRow("if(error())")
<< "if(error(\\'World, you FAIL!\\')): OK = 1\nOKE = 1"
<< "OK = UNDEF\nOKE = UNDEF"