forked from qt-creator/qt-creator
AutoTest: More filepathification
Change-Id: Ibb76f4332fa2e682709520cebe5e243dc3b70bb2 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -235,7 +235,7 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
|
||||
parseResult->proFile = proFile;
|
||||
parseResult->itemType = TestTreeItem::TestCase;
|
||||
if (!testCaseName.isEmpty()) {
|
||||
parseResult->fileName = Utils::FilePath::fromString(testCase.m_locationAndType.m_name);
|
||||
parseResult->fileName = testCase.m_locationAndType.m_filePath;
|
||||
parseResult->name = testCaseName;
|
||||
parseResult->line = testCase.m_locationAndType.m_line;
|
||||
parseResult->column = testCase.m_locationAndType.m_column;
|
||||
@@ -243,12 +243,12 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr
|
||||
|
||||
for (const auto &function : testCase.m_functions) {
|
||||
QuickTestParseResult *funcResult = new QuickTestParseResult(framework);
|
||||
funcResult->name = function.m_functionName;
|
||||
funcResult->displayName = function.m_functionName;
|
||||
funcResult->itemType = function.m_locationAndType.m_type;
|
||||
funcResult->fileName = Utils::FilePath::fromString(function.m_locationAndType.m_name);
|
||||
funcResult->line = function.m_locationAndType.m_line;
|
||||
funcResult->column = function.m_locationAndType.m_column;
|
||||
funcResult->name = function.m_name;
|
||||
funcResult->displayName = function.m_name;
|
||||
funcResult->itemType = function.m_type;
|
||||
funcResult->fileName = function.m_filePath;
|
||||
funcResult->line = function.m_line;
|
||||
funcResult->column = function.m_column;
|
||||
funcResult->proFile = proFile;
|
||||
|
||||
parseResult->children.append(funcResult);
|
||||
|
||||
@@ -99,7 +99,7 @@ bool TestQmlVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
|
||||
m_objectIsTestStack.top() = true;
|
||||
const auto sourceLocation = ast->firstSourceLocation();
|
||||
QuickTestCaseSpec currentSpec;
|
||||
currentSpec.m_locationAndType.m_name = m_currentDoc->fileName();
|
||||
currentSpec.m_locationAndType.m_filePath = Utils::FilePath::fromString(m_currentDoc->fileName());
|
||||
currentSpec.m_locationAndType.m_line = sourceLocation.startLine;
|
||||
currentSpec.m_locationAndType.m_column = sourceLocation.startColumn - 1;
|
||||
currentSpec.m_locationAndType.m_type = TestTreeItem::TestCase;
|
||||
@@ -139,10 +139,11 @@ bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
|
||||
|
||||
const QString name = ast->name.toString();
|
||||
if (name.startsWith("test_") || name.startsWith("benchmark_") || name.endsWith("_data")
|
||||
|| specialFunctions.contains(name)) {
|
||||
|| specialFunctions.contains(name)) {
|
||||
const auto sourceLocation = ast->firstSourceLocation();
|
||||
TestCodeLocationAndType locationAndType;
|
||||
locationAndType.m_name = m_currentDoc->fileName();
|
||||
locationAndType.m_name = name;
|
||||
locationAndType.m_filePath = Utils::FilePath::fromString(m_currentDoc->fileName());
|
||||
locationAndType.m_line = sourceLocation.startLine;
|
||||
locationAndType.m_column = sourceLocation.startColumn - 1;
|
||||
if (specialFunctions.contains(name))
|
||||
@@ -152,16 +153,14 @@ bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
|
||||
else
|
||||
locationAndType.m_type = TestTreeItem::TestFunction;
|
||||
|
||||
const QString nameStr = name;
|
||||
// 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;
|
||||
[locationAndType](const TestCodeLocationAndType &func) {
|
||||
return func.m_type == locationAndType.m_type
|
||||
&& func.m_name == locationAndType.m_name
|
||||
&& func.m_filePath == locationAndType.m_filePath;
|
||||
})) {
|
||||
m_caseParseStack.top().m_functions.append(
|
||||
QuickTestFunctionSpec{nameStr, locationAndType});
|
||||
m_caseParseStack.top().m_functions.append(locationAndType);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -37,19 +37,12 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class QuickTestFunctionSpec
|
||||
{
|
||||
public:
|
||||
QString m_functionName;
|
||||
TestCodeLocationAndType m_locationAndType;
|
||||
};
|
||||
|
||||
class QuickTestCaseSpec
|
||||
{
|
||||
public:
|
||||
QString m_caseName;
|
||||
TestCodeLocationAndType m_locationAndType;
|
||||
QVector<QuickTestFunctionSpec> m_functions;
|
||||
TestCodeLocationList m_functions;
|
||||
};
|
||||
|
||||
class TestQmlVisitor : public QmlJS::AST::Visitor
|
||||
|
||||
Reference in New Issue
Block a user