forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user