2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2016-05-11 13:02:42 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "../itestparser.h"
|
|
|
|
|
|
2021-04-23 13:40:46 +02:00
|
|
|
#include "qttest_utils.h"
|
2021-01-01 19:19:10 +01:00
|
|
|
#include "qttesttreeitem.h"
|
|
|
|
|
|
2022-08-26 10:30:00 +02:00
|
|
|
#include <optional>
|
2021-04-23 11:44:52 +02:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
namespace CppEditor { class CppModelManager; }
|
2021-01-01 19:19:10 +01:00
|
|
|
|
2016-05-11 13:02:42 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class QtTestParseResult : public TestParseResult
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-01-25 16:31:16 +01:00
|
|
|
explicit QtTestParseResult(ITestFramework *framework) : TestParseResult(framework) {}
|
2017-01-04 12:06:46 +01:00
|
|
|
void setInherited(bool inherited) { m_inherited = inherited; }
|
|
|
|
|
bool inherited() const { return m_inherited; }
|
2021-04-23 13:40:46 +02:00
|
|
|
void setRunsMultipleTestcases(bool multi) { m_multiTest = multi; }
|
|
|
|
|
bool runsMultipleTestcases() const { return m_multiTest; }
|
2016-05-11 13:02:42 +02:00
|
|
|
TestTreeItem *createTestTreeItem() const override;
|
2017-01-04 12:06:46 +01:00
|
|
|
private:
|
|
|
|
|
bool m_inherited = false;
|
2021-04-23 13:40:46 +02:00
|
|
|
bool m_multiTest = false;
|
2016-05-11 13:02:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QtTestParser : public CppParser
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-03-13 13:54:33 +01:00
|
|
|
explicit QtTestParser(ITestFramework *framework) : CppParser(framework) {}
|
|
|
|
|
|
2023-04-23 17:25:46 +02:00
|
|
|
void init(const QSet<Utils::FilePath> &filesToParse, bool fullParse) override;
|
2016-07-12 10:35:43 +02:00
|
|
|
void release() override;
|
2023-02-12 01:31:47 +01:00
|
|
|
bool processDocument(QPromise<TestParseResultPtr> &promise,
|
2021-05-26 15:50:03 +02:00
|
|
|
const Utils::FilePath &fileName) override;
|
2016-05-11 13:02:42 +02:00
|
|
|
|
|
|
|
|
private:
|
2021-08-30 10:58:08 +02:00
|
|
|
TestCases testCases(const CppEditor::CppModelManager *modelManager,
|
2021-04-23 13:40:46 +02:00
|
|
|
const Utils::FilePath &fileName) const;
|
2021-06-16 16:06:34 +02:00
|
|
|
QHash<QString, QtTestCodeLocationList> checkForDataTags(const Utils::FilePath &fileName) const;
|
2021-04-23 11:44:52 +02:00
|
|
|
struct TestCaseData {
|
2021-05-26 15:50:03 +02:00
|
|
|
Utils::FilePath fileName;
|
2021-04-23 11:44:52 +02:00
|
|
|
int line = 0;
|
|
|
|
|
int column = 0;
|
|
|
|
|
QMap<QString, QtTestCodeLocationAndType> testFunctions;
|
|
|
|
|
QHash<QString, QtTestCodeLocationList> dataTags;
|
2021-04-23 13:40:46 +02:00
|
|
|
bool multipleTestCases = false;
|
2021-04-23 11:44:52 +02:00
|
|
|
bool valid = false;
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-26 10:30:00 +02:00
|
|
|
std::optional<bool> fillTestCaseData(const QString &testCaseName,
|
2021-04-23 11:44:52 +02:00
|
|
|
const CPlusPlus::Document::Ptr &doc,
|
|
|
|
|
TestCaseData &data) const;
|
|
|
|
|
QtTestParseResult *createParseResult(const QString &testCaseName, const TestCaseData &data,
|
|
|
|
|
const QString &projectFile) const;
|
2021-04-23 13:40:46 +02:00
|
|
|
QHash<Utils::FilePath, TestCases> m_testCases;
|
2021-05-26 15:50:03 +02:00
|
|
|
QMultiHash<Utils::FilePath, Utils::FilePath> m_alternativeFiles;
|
2016-05-11 13:02:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|