diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-08-22 09:53:37 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-08-22 09:53:37 +0200 |
commit | 30143478f3a15c0e6d9a731730b66d78f1ae334a (patch) | |
tree | 1178feb634379c1bf705e6ad8d778539618647c3 /src/plugins/autotest | |
parent | d0bdfad93284ec8de3026d21ae3d845318e317fc (diff) | |
parent | 8cd7a119262c226e575c0beda45a1af71a32baf5 (diff) | |
download | qt-creator-30143478f3a15c0e6d9a731730b66d78f1ae334a.tar.gz |
Merge remote-tracking branch 'origin/4.10'
Conflicts:
src/libs/utils/consoleprocess_win.cpp
Change-Id: Ibdc265eed2f7080726e11ff6f2931c8559943af2
Diffstat (limited to 'src/plugins/autotest')
6 files changed, 37 insertions, 10 deletions
diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index b571ed1354..4897e98efa 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -131,13 +131,13 @@ void AutoTestUnitTests::testCodeParser_data() << 1 << 0 << 0 << 0; QTest::newRow("mixedAutoTestAndQuickTests") << QString(m_tmpDir->path() + "/mixed_atp/mixed_atp.pro") - << 4 << 10 << 4 << 10; + << 4 << 10 << 5 << 10; QTest::newRow("plainAutoTestQbs") << QString(m_tmpDir->path() + "/plain/plain.qbs") << 1 << 0 << 0 << 0; QTest::newRow("mixedAutoTestAndQuickTestsQbs") << QString(m_tmpDir->path() + "/mixed_atp/mixed_atp.qbs") - << 4 << 10 << 4 << 10; + << 4 << 10 << 5 << 10; } void AutoTestUnitTests::testCodeParserSwitchStartup() @@ -184,7 +184,7 @@ void AutoTestUnitTests::testCodeParserSwitchStartup_data() QList<int> expectedAutoTests = QList<int>() << 1 << 4 << 1 << 4; QList<int> expectedNamedQuickTests = QList<int>() << 0 << 10 << 0 << 10; - QList<int> expectedUnnamedQuickTests = QList<int>() << 0 << 4 << 0 << 4; + QList<int> expectedUnnamedQuickTests = QList<int>() << 0 << 5 << 0 << 5; QList<int> expectedDataTagsCount = QList<int>() << 0 << 10 << 0 << 10; QTest::newRow("loadMultipleProjects") diff --git a/src/plugins/autotest/qtest/qttestresult.cpp b/src/plugins/autotest/qtest/qttestresult.cpp index 3e85c36e68..65ec0c8270 100644 --- a/src/plugins/autotest/qtest/qttestresult.cpp +++ b/src/plugins/autotest/qtest/qttestresult.cpp @@ -95,7 +95,8 @@ bool QtTestResult::isDirectParentOf(const TestResult *other, bool *needsIntermed return qtOther->m_dataTag == m_dataTag; } } else if (qtOther->isTestFunction()) { - return isTestCase() || m_function == qtOther->m_function; + return isTestCase() || (m_function == qtOther->m_function + && qtOther->result() != ResultType::TestStart); } } return false; diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp index c18de0ee9e..85f459ea01 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.cpp +++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp @@ -329,7 +329,8 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result) case GroupNode: return findChildByNameAndFile(result->name, result->fileName); case TestCase: - return name().isEmpty() ? findChildByNameAndFile(result->name, result->fileName) + return name().isEmpty() ? findChildByNameFileAndLine(result->name, result->fileName, + result->line) : findChildByName(result->name); default: return nullptr; @@ -351,7 +352,8 @@ TestTreeItem *QuickTestTreeItem::findChild(const TestTreeItem *other) case TestCase: if (otherType != TestFunction && otherType != TestDataFunction && otherType != TestSpecialFunction) return nullptr; - return name().isEmpty() ? findChildByNameAndFile(other->name(), other->filePath()) + return name().isEmpty() ? findChildByNameFileAndLine(other->name(), other->filePath(), + other->line()) : findChildByName(other->name()); default: return nullptr; @@ -368,8 +370,7 @@ bool QuickTestTreeItem::modify(const TestParseResult *result) case TestFunction: case TestDataFunction: case TestSpecialFunction: - return name().isEmpty() ? modifyLineAndColumn(result) - : modifyTestFunctionContent(result); + return modifyTestFunctionContent(result); default: return false; } @@ -454,6 +455,14 @@ TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const QString &fileP }); } +TestTreeItem *QuickTestTreeItem::findChildByNameFileAndLine(const QString &name, + const QString &filePath, unsigned line) +{ + return findFirstLevelChild([name, filePath, line](const TestTreeItem *other) { + return other->filePath() == filePath && other->line() == line && other->name() == name; + }); +} + TestTreeItem *QuickTestTreeItem::unnamedQuickTests() const { if (type() != Root) diff --git a/src/plugins/autotest/quick/quicktesttreeitem.h b/src/plugins/autotest/quick/quicktesttreeitem.h index a9e48fca94..551d0865a2 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.h +++ b/src/plugins/autotest/quick/quicktesttreeitem.h @@ -59,6 +59,8 @@ public: private: TestTreeItem *findChildByFileNameAndType(const QString &filePath, const QString &name, Type tType); + TestTreeItem *findChildByNameFileAndLine(const QString &name, const QString &filePath, + unsigned line); TestTreeItem *unnamedQuickTests() const; }; diff --git a/src/plugins/autotest/quick/quicktestvisitors.cpp b/src/plugins/autotest/quick/quicktestvisitors.cpp index f60b59b368..486356f13b 100644 --- a/src/plugins/autotest/quick/quicktestvisitors.cpp +++ b/src/plugins/autotest/quick/quicktestvisitors.cpp @@ -152,8 +152,17 @@ bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast) else locationAndType.m_type = TestTreeItem::TestFunction; - m_caseParseStack.top().m_functions.append( - QuickTestFunctionSpec{name.toString(), locationAndType}); + const QString nameStr = name.toString(); + // identical test functions inside the same file are not working - will fail at runtime + if (!Utils::anyOf(m_caseParseStack.top().m_functions, + [nameStr, locationAndType](const QuickTestFunctionSpec func) { + return func.m_locationAndType.m_type == locationAndType.m_type + && func.m_functionName == nameStr + && func.m_locationAndType.m_name == locationAndType.m_name; + })) { + m_caseParseStack.top().m_functions.append( + QuickTestFunctionSpec{nameStr, locationAndType}); + } } return false; } diff --git a/src/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml b/src/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml index b6330ac4ea..68fd193c52 100644 --- a/src/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml +++ b/src/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml @@ -67,5 +67,11 @@ TestCase { verify(true); } } + + TestCase { // 2nd unnamed with same function name - legal as long it's a different TestCase + function test_func() { + verify(true); + } + } } |