AutoTest: Fix handling of unnamed QuickTests

..now that the parser understands multiple TestCase items
inside a single qml file.
As long a test function is located inside a different TestCase
it is considered as a different one, so treat test functions
even of unnamed test cases correct.

Change-Id: I5cbfe1f63f896317523d51bbf67ea59169481a71
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-07-30 15:14:40 +02:00
parent abe3dde5d6
commit 8cd7a11926
6 changed files with 37 additions and 10 deletions

View File

@@ -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;
}