From bcafe202c9f8a7c4bad4cf60095138b1d6cbf2ac Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sun, 30 Dec 2018 15:45:04 +0100 Subject: [PATCH] AutoTest: Allow redefinition of integrated QTest macros Undefining the macro could lead to a crash when evaluating the arguments; at least the test was not recognized (probably as the loop was exited at the first ocurrence of the macro name). Use case: #ifdef QTEST_APPLESS_MAIN # undef QTEST_APPLESS_MAIN # define QTEST_APPLESS_MAIN TF_TEST_MAIN #endif QTEST_APPLESS_MAIN(tst_MyClass) Task-number: QTCREATORBUG-19910 Change-Id: I9f935f82a30b9681398e5d93fccfe6d474765022 Reviewed-by: Robert Szefner Reviewed-by: Christian Stenger --- src/plugins/autotest/qtest/qttestparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/autotest/qtest/qttestparser.cpp b/src/plugins/autotest/qtest/qttestparser.cpp index b806e79f8d3..234aeca79f9 100644 --- a/src/plugins/autotest/qtest/qttestparser.cpp +++ b/src/plugins/autotest/qtest/qttestparser.cpp @@ -107,7 +107,7 @@ static QString testClass(const CppTools::CppModelManager *modelManager, if (!macro.isFunctionLike()) continue; const QByteArray name = macro.macro().name(); - if (QTestUtils::isQTestMacro(name)) { + if (QTestUtils::isQTestMacro(name) && !macro.arguments().isEmpty()) { const CPlusPlus::Document::Block arg = macro.arguments().at(0); return QLatin1String(fileContent.mid(int(arg.bytesBegin()), int(arg.bytesEnd() - arg.bytesBegin())));