2016-05-11 13:02:42 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
2021-04-23 11:44:52 +02:00
|
|
|
#include <utils/optional.h>
|
|
|
|
|
|
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) {}
|
|
|
|
|
|
2021-05-26 15:50:03 +02:00
|
|
|
void init(const Utils::FilePaths &filesToParse, bool fullParse) override;
|
2016-07-12 10:35:43 +02:00
|
|
|
void release() override;
|
2021-08-27 09:59:07 +02:00
|
|
|
bool processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Utils::optional<bool> fillTestCaseData(const QString &testCaseName,
|
|
|
|
|
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
|