forked from qt-creator/qt-creator
AutoTest: Use using namespace Utils more often
Change-Id: I9d20cd3496c4719d58a977f8fd53253c86d55463 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -66,6 +66,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -361,7 +362,7 @@ void AutotestPluginPrivate::onRunFileTriggered()
|
|||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Utils::FilePath &fileName = document->filePath();
|
const FilePath &fileName = document->filePath();
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -398,7 +399,7 @@ void AutotestPluginPrivate::onRunUnderCursorTriggered(TestRunMode mode)
|
|||||||
|
|
||||||
// check whether we have been triggered on a test function definition
|
// check whether we have been triggered on a test function definition
|
||||||
const int line = currentEditor->currentLine();
|
const int line = currentEditor->currentLine();
|
||||||
const Utils::FilePath &filePath = currentEditor->textDocument()->filePath();
|
const FilePath &filePath = currentEditor->textDocument()->filePath();
|
||||||
QList<ITestTreeItem *> filteredItems = Utils::filtered(testsItems, [&](ITestTreeItem *it){
|
QList<ITestTreeItem *> filteredItems = Utils::filtered(testsItems, [&](ITestTreeItem *it){
|
||||||
return it->line() == line && it->filePath() == filePath;
|
return it->line() == line && it->filePath() == filePath;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void AutoTestUnitTests::initTestCase()
|
|||||||
if (!qtcEnvironmentVariableIsEmpty("BOOST_INCLUDE_DIR")) {
|
if (!qtcEnvironmentVariableIsEmpty("BOOST_INCLUDE_DIR")) {
|
||||||
m_checkBoost = true;
|
m_checkBoost = true;
|
||||||
} else {
|
} else {
|
||||||
if (Utils::HostOsInfo::isLinuxHost()
|
if (HostOsInfo::isLinuxHost()
|
||||||
&& (QFileInfo::exists("/usr/include/boost/version.hpp")
|
&& (QFileInfo::exists("/usr/include/boost/version.hpp")
|
||||||
|| QFileInfo::exists("/usr/local/include/boost/version.hpp"))) {
|
|| QFileInfo::exists("/usr/local/include/boost/version.hpp"))) {
|
||||||
qDebug() << "Found boost at system level - will run boost parser test.";
|
qDebug() << "Found boost at system level - will run boost parser test.";
|
||||||
@@ -77,7 +77,7 @@ void AutoTestUnitTests::initTestCase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable quick check for derived tests
|
// Enable quick check for derived tests
|
||||||
static const Utils::Id id = Utils::Id("AutoTest.Framework.QtTest");
|
static const Id id = Id("AutoTest.Framework.QtTest");
|
||||||
static_cast<Autotest::Internal::QtTestSettings *>(
|
static_cast<Autotest::Internal::QtTestSettings *>(
|
||||||
TestFrameworkManager::frameworkForId(id)->testSettings())
|
TestFrameworkManager::frameworkForId(id)->testSettings())
|
||||||
->quickCheckForDerivedTests.setValue(true);
|
->quickCheckForDerivedTests.setValue(true);
|
||||||
@@ -257,7 +257,7 @@ void AutoTestUnitTests::testCodeParserBoostTest()
|
|||||||
|
|
||||||
QCOMPARE(m_model->boostTestNamesCount(), 5);
|
QCOMPARE(m_model->boostTestNamesCount(), 5);
|
||||||
|
|
||||||
const Utils::FilePath basePath = projectInfo->projectRoot();
|
const FilePath basePath = projectInfo->projectRoot();
|
||||||
QVERIFY(!basePath.isEmpty());
|
QVERIFY(!basePath.isEmpty());
|
||||||
|
|
||||||
QMap<QString, int> expectedSuitesAndTests;
|
QMap<QString, int> expectedSuitesAndTests;
|
||||||
|
|||||||
@@ -13,11 +13,13 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
TestOutputReader *BoostTestConfiguration::createOutputReader(
|
TestOutputReader *BoostTestConfiguration::createOutputReader(
|
||||||
const QFutureInterface<TestResult> &fi, Utils::QtcProcess *app) const
|
const QFutureInterface<TestResult> &fi, QtcProcess *app) const
|
||||||
{
|
{
|
||||||
auto settings = static_cast<BoostTestSettings *>(framework()->testSettings());
|
auto settings = static_cast<BoostTestSettings *>(framework()->testSettings());
|
||||||
return new BoostTestOutputReader(fi, app, buildDirectory(), projectFile(),
|
return new BoostTestOutputReader(fi, app, buildDirectory(), projectFile(),
|
||||||
@@ -113,11 +115,11 @@ QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted)
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Environment BoostTestConfiguration::filteredEnvironment(const Utils::Environment &original) const
|
Environment BoostTestConfiguration::filteredEnvironment(const Environment &original) const
|
||||||
{
|
{
|
||||||
const QStringList interferingEnv = interfering(InterferingType::EnvironmentVariables);
|
const QStringList interferingEnv = interfering(InterferingType::EnvironmentVariables);
|
||||||
|
|
||||||
Utils::Environment result = original;
|
Environment result = original;
|
||||||
if (!result.hasKey("BOOST_TEST_COLOR_OUTPUT"))
|
if (!result.hasKey("BOOST_TEST_COLOR_OUTPUT"))
|
||||||
result.set("BOOST_TEST_COLOR_OUTPUT", "1"); // use colored output by default
|
result.set("BOOST_TEST_COLOR_OUTPUT", "1"); // use colored output by default
|
||||||
for (const QString &key : interferingEnv)
|
for (const QString &key : interferingEnv)
|
||||||
|
|||||||
@@ -14,15 +14,17 @@
|
|||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static Q_LOGGING_CATEGORY(orLog, "qtc.autotest.boost.outputreader", QtWarningMsg)
|
static Q_LOGGING_CATEGORY(orLog, "qtc.autotest.boost.outputreader", QtWarningMsg)
|
||||||
|
|
||||||
BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||||
Utils::QtcProcess *testApplication,
|
QtcProcess *testApplication,
|
||||||
const Utils::FilePath &buildDirectory,
|
const FilePath &buildDirectory,
|
||||||
const Utils::FilePath &projectFile,
|
const FilePath &projectFile,
|
||||||
LogLevel log, ReportLevel report)
|
LogLevel log, ReportLevel report)
|
||||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||||
, m_projectFile(projectFile)
|
, m_projectFile(projectFile)
|
||||||
@@ -30,7 +32,7 @@ BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResult>
|
|||||||
, m_reportLevel(report)
|
, m_reportLevel(report)
|
||||||
{
|
{
|
||||||
if (m_testApplication)
|
if (m_testApplication)
|
||||||
connect(m_testApplication, &Utils::QtcProcess::done, this, &BoostTestOutputReader::onDone);
|
connect(m_testApplication, &QtcProcess::done, this, &BoostTestOutputReader::onDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// content of "error:..." / "info:..." / ... messages
|
// content of "error:..." / "info:..." / ... messages
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ static bool hasBoostTestMacros(const CPlusPlus::Document::Ptr &doc)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BoostTestParseResult *createParseResult(const QString &name, const Utils::FilePath &filePath,
|
static BoostTestParseResult *createParseResult(const QString &name, const FilePath &filePath,
|
||||||
const Utils::FilePath &projectFile,
|
const FilePath &projectFile,
|
||||||
ITestFramework *framework,
|
ITestFramework *framework,
|
||||||
TestTreeItem::Type type, const BoostTestInfo &info)
|
TestTreeItem::Type type, const BoostTestInfo &info)
|
||||||
{
|
{
|
||||||
@@ -97,7 +97,7 @@ static BoostTestParseResult *createParseResult(const QString &name, const Utils:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||||
const Utils::FilePath &fileName)
|
const FilePath &fileName)
|
||||||
{
|
{
|
||||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||||
if (doc.isNull() || !includesBoostTest(doc, m_cppSnapshot) || !hasBoostTestMacros(doc))
|
if (doc.isNull() || !includesBoostTest(doc, m_cppSnapshot) || !hasBoostTestMacros(doc))
|
||||||
@@ -109,7 +109,7 @@ bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futu
|
|||||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||||
const auto projectFile = Utils::FilePath::fromString(projectPart->projectFile);
|
const auto projectFile = FilePath::fromString(projectPart->projectFile);
|
||||||
const QByteArray &fileContent = getFileContent(fileName);
|
const QByteArray &fileContent = getFileContent(fileName);
|
||||||
|
|
||||||
BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot);
|
BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot);
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ BoostTestSettings::BoostTestSettings()
|
|||||||
memLeaks.setToolTip(Tr::tr("Enable memory leak detection."));
|
memLeaks.setToolTip(Tr::tr("Enable memory leak detection."));
|
||||||
}
|
}
|
||||||
|
|
||||||
BoostTestSettingsPage::BoostTestSettingsPage(BoostTestSettings *settings, Utils::Id settingsId)
|
BoostTestSettingsPage::BoostTestSettingsPage(BoostTestSettings *settings, Id settingsId)
|
||||||
{
|
{
|
||||||
setId(settingsId);
|
setId(settingsId);
|
||||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -123,7 +125,7 @@ bool BoostTestTreeItem::modify(const TestParseResult *result)
|
|||||||
|
|
||||||
TestTreeItem *BoostTestTreeItem::createParentGroupNode() const
|
TestTreeItem *BoostTestTreeItem::createParentGroupNode() const
|
||||||
{
|
{
|
||||||
const Utils::FilePath &absPath = filePath().absolutePath();
|
const FilePath &absPath = filePath().absolutePath();
|
||||||
return new BoostTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
return new BoostTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +166,7 @@ QList<ITestConfiguration *> BoostTestTreeItem::getAllTestConfigurations() const
|
|||||||
};
|
};
|
||||||
|
|
||||||
// we only need the unique project files (and number of test cases for the progress indicator)
|
// we only need the unique project files (and number of test cases for the progress indicator)
|
||||||
QHash<Utils::FilePath, BoostTestCases> testsPerProjectfile;
|
QHash<FilePath, BoostTestCases> testsPerProjectfile;
|
||||||
forAllChildItems([&testsPerProjectfile](TestTreeItem *item){
|
forAllChildItems([&testsPerProjectfile](TestTreeItem *item){
|
||||||
if (item->type() != TestSuite)
|
if (item->type() != TestSuite)
|
||||||
return;
|
return;
|
||||||
@@ -207,7 +209,7 @@ QList<ITestConfiguration *> BoostTestTreeItem::getTestConfigurations(
|
|||||||
QSet<QString> internalTargets;
|
QSet<QString> internalTargets;
|
||||||
};
|
};
|
||||||
|
|
||||||
QHash<Utils::FilePath, BoostTestCases> testCasesForProjectFile;
|
QHash<FilePath, BoostTestCases> testCasesForProjectFile;
|
||||||
forAllChildren([&testCasesForProjectFile, &predicate](TreeItem *it){
|
forAllChildren([&testCasesForProjectFile, &predicate](TreeItem *it){
|
||||||
auto item = static_cast<BoostTestTreeItem *>(it);
|
auto item = static_cast<BoostTestTreeItem *>(it);
|
||||||
if (item->type() != TestCase)
|
if (item->type() != TestCase)
|
||||||
@@ -346,10 +348,10 @@ bool BoostTestTreeItem::enabled() const
|
|||||||
|
|
||||||
TestTreeItem *BoostTestTreeItem::findChildByNameStateAndFile(const QString &name,
|
TestTreeItem *BoostTestTreeItem::findChildByNameStateAndFile(const QString &name,
|
||||||
BoostTestTreeItem::TestStates state,
|
BoostTestTreeItem::TestStates state,
|
||||||
const Utils::FilePath &proFile) const
|
const FilePath &proFile) const
|
||||||
{
|
{
|
||||||
return static_cast<TestTreeItem *>(
|
return static_cast<TestTreeItem *>(
|
||||||
findAnyChild([name, state, proFile](const Utils::TreeItem *other){
|
findAnyChild([name, state, proFile](const TreeItem *other){
|
||||||
const BoostTestTreeItem *boostItem = static_cast<const BoostTestTreeItem *>(other);
|
const BoostTestTreeItem *boostItem = static_cast<const BoostTestTreeItem *>(other);
|
||||||
return boostItem->proFile() == proFile && boostItem->fullName() == name
|
return boostItem->proFile() == proFile && boostItem->fullName() == name
|
||||||
&& boostItem->state() == state;
|
&& boostItem->state() == state;
|
||||||
|
|||||||
@@ -11,11 +11,13 @@
|
|||||||
|
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
TestOutputReader *CatchConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
TestOutputReader *CatchConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||||
Utils::QtcProcess *app) const
|
QtcProcess *app) const
|
||||||
{
|
{
|
||||||
return new CatchOutputReader(fi, app, buildDirectory(), projectFile());
|
return new CatchOutputReader(fi, app, buildDirectory(), projectFile());
|
||||||
}
|
}
|
||||||
@@ -115,7 +117,7 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Environment CatchConfiguration::filteredEnvironment(const Utils::Environment &original) const
|
Environment CatchConfiguration::filteredEnvironment(const Environment &original) const
|
||||||
{
|
{
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -30,9 +32,9 @@ namespace CatchXml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CatchOutputReader::CatchOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
CatchOutputReader::CatchOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||||
Utils::QtcProcess *testApplication,
|
QtcProcess *testApplication,
|
||||||
const Utils::FilePath &buildDirectory,
|
const FilePath &buildDirectory,
|
||||||
const Utils::FilePath &projectFile)
|
const FilePath &projectFile)
|
||||||
: TestOutputReader (futureInterface, testApplication, buildDirectory)
|
: TestOutputReader (futureInterface, testApplication, buildDirectory)
|
||||||
, m_projectFile(projectFile)
|
, m_projectFile(projectFile)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ static bool hasCatchNames(const CPlusPlus::Document::Ptr &document)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||||
const Utils::FilePath &fileName)
|
const FilePath &fileName)
|
||||||
{
|
{
|
||||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||||
if (doc.isNull() || !includesCatchHeader(doc, m_cppSnapshot))
|
if (doc.isNull() || !includesCatchHeader(doc, m_cppSnapshot))
|
||||||
@@ -117,9 +117,9 @@ bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futu
|
|||||||
const QList<CppEditor::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(fileName);
|
const QList<CppEditor::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(fileName);
|
||||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
Utils::FilePath proFile;
|
FilePath proFile;
|
||||||
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||||
proFile = Utils::FilePath::fromString(projectPart->projectFile);
|
proFile = FilePath::fromString(projectPart->projectFile);
|
||||||
|
|
||||||
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
||||||
const CatchTestCodeLocationList foundTests = codeParser.findTests();
|
const CatchTestCodeLocationList foundTests = codeParser.findTests();
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ CatchTestSettings::CatchTestSettings()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CatchTestSettingsPage::CatchTestSettingsPage(CatchTestSettings *settings, Utils::Id settingsId)
|
CatchTestSettingsPage::CatchTestSettingsPage(CatchTestSettings *settings, Id settingsId)
|
||||||
{
|
{
|
||||||
setId(settingsId);
|
setId(settingsId);
|
||||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result)
|
|||||||
switch (type()) {
|
switch (type()) {
|
||||||
case Root:
|
case Root:
|
||||||
if (result->framework->grouping()) {
|
if (result->framework->grouping()) {
|
||||||
const Utils::FilePath path = result->fileName.absolutePath();
|
const FilePath path = result->fileName.absolutePath();
|
||||||
for (int row = 0; row < childCount(); ++row) {
|
for (int row = 0; row < childCount(); ++row) {
|
||||||
TestTreeItem *group = childItem(row);
|
TestTreeItem *group = childItem(row);
|
||||||
if (group->filePath() != path)
|
if (group->filePath() != path)
|
||||||
@@ -123,7 +125,7 @@ bool CatchTreeItem::modify(const TestParseResult *result)
|
|||||||
|
|
||||||
TestTreeItem *CatchTreeItem::createParentGroupNode() const
|
TestTreeItem *CatchTreeItem::createParentGroupNode() const
|
||||||
{
|
{
|
||||||
const Utils::FilePath absPath = filePath().absolutePath();
|
const FilePath absPath = filePath().absolutePath();
|
||||||
return new CatchTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
return new CatchTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +174,7 @@ struct CatchTestCases
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void collectTestInfo(const TestTreeItem *item,
|
static void collectTestInfo(const TestTreeItem *item,
|
||||||
QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile,
|
QHash<FilePath, CatchTestCases> &testCasesForProfile,
|
||||||
bool ignoreCheckState)
|
bool ignoreCheckState)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(item, return);
|
QTC_ASSERT(item, return);
|
||||||
@@ -189,7 +191,7 @@ static void collectTestInfo(const TestTreeItem *item,
|
|||||||
QTC_ASSERT(childCount != 0, return);
|
QTC_ASSERT(childCount != 0, return);
|
||||||
QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return);
|
QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return);
|
||||||
if (ignoreCheckState || item->checked() == Qt::Checked) {
|
if (ignoreCheckState || item->checked() == Qt::Checked) {
|
||||||
const Utils::FilePath &projectFile = item->childItem(0)->proFile();
|
const FilePath &projectFile = item->childItem(0)->proFile();
|
||||||
item->forAllChildItems([&testCasesForProfile, &projectFile](TestTreeItem *it) {
|
item->forAllChildItems([&testCasesForProfile, &projectFile](TestTreeItem *it) {
|
||||||
CatchTreeItem *current = static_cast<CatchTreeItem *>(it);
|
CatchTreeItem *current = static_cast<CatchTreeItem *>(it);
|
||||||
testCasesForProfile[projectFile].names.append(current->testCasesString());
|
testCasesForProfile[projectFile].names.append(current->testCasesString());
|
||||||
@@ -210,7 +212,7 @@ static void collectTestInfo(const TestTreeItem *item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void collectFailedTestInfo(const CatchTreeItem *item,
|
static void collectFailedTestInfo(const CatchTreeItem *item,
|
||||||
QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile)
|
QHash<FilePath, CatchTestCases> &testCasesForProfile)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(item, return);
|
QTC_ASSERT(item, return);
|
||||||
QTC_ASSERT(item->type() == TestTreeItem::Root, return);
|
QTC_ASSERT(item->type() == TestTreeItem::Root, return);
|
||||||
@@ -246,7 +248,7 @@ QList<ITestConfiguration *> CatchTreeItem::getFailedTestConfigurations() const
|
|||||||
if (!project || type() != Root)
|
if (!project || type() != Root)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QHash<Utils::FilePath, CatchTestCases> testCasesForProFile;
|
QHash<FilePath, CatchTestCases> testCasesForProFile;
|
||||||
collectFailedTestInfo(this, testCasesForProFile);
|
collectFailedTestInfo(this, testCasesForProFile);
|
||||||
|
|
||||||
for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) {
|
for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) {
|
||||||
@@ -263,7 +265,7 @@ QList<ITestConfiguration *> CatchTreeItem::getFailedTestConfigurations() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ITestConfiguration *> CatchTreeItem::getTestConfigurationsForFile(const Utils::FilePath &fileName) const
|
QList<ITestConfiguration *> CatchTreeItem::getTestConfigurationsForFile(const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
QList<ITestConfiguration *> result;
|
QList<ITestConfiguration *> result;
|
||||||
const auto cppMM = CppEditor::CppModelManager::instance();
|
const auto cppMM = CppEditor::CppModelManager::instance();
|
||||||
@@ -316,7 +318,7 @@ QList<ITestConfiguration *> CatchTreeItem::getTestConfigurations(bool ignoreChec
|
|||||||
if (!project || type() != Root)
|
if (!project || type() != Root)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QHash<Utils::FilePath, CatchTestCases> testCasesForProfile;
|
QHash<FilePath, CatchTestCases> testCasesForProfile;
|
||||||
for (int row = 0, end = childCount(); row < end; ++row)
|
for (int row = 0, end = childCount(); row < end; ++row)
|
||||||
collectTestInfo(childItem(row), testCasesForProfile, ignoreCheckState);
|
collectTestInfo(childItem(row), testCasesForProfile, ignoreCheckState);
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
CTestOutputReader::CTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
CTestOutputReader::CTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||||
Utils::QtcProcess *testApplication,
|
QtcProcess *testApplication,
|
||||||
const Utils::FilePath &buildDirectory)
|
const FilePath &buildDirectory)
|
||||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,13 @@
|
|||||||
#include <utils/link.h>
|
#include <utils/link.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
CTestTreeItem::CTestTreeItem(ITestBase *testBase, const QString &name,
|
CTestTreeItem::CTestTreeItem(ITestBase *testBase, const QString &name,
|
||||||
const Utils::FilePath &filepath, Type type)
|
const FilePath &filepath, Type type)
|
||||||
: ITestTreeItem(testBase, name, filepath, type)
|
: ITestTreeItem(testBase, name, filepath, type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -69,7 +71,7 @@ QVariant CTestTreeItem::data(int column, int role) const
|
|||||||
return checked();
|
return checked();
|
||||||
if (role == LinkRole) {
|
if (role == LinkRole) {
|
||||||
QVariant itemLink;
|
QVariant itemLink;
|
||||||
itemLink.setValue(Utils::Link(filePath(), line()));
|
itemLink.setValue(Link(filePath(), line()));
|
||||||
return itemLink;
|
return itemLink;
|
||||||
}
|
}
|
||||||
return ITestTreeItem::data(column, role);
|
return ITestTreeItem::data(column, role);
|
||||||
@@ -89,7 +91,7 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi
|
|||||||
QStringList options{"--timeout", QString::number(AutotestPlugin::settings()->timeout / 1000)};
|
QStringList options{"--timeout", QString::number(AutotestPlugin::settings()->timeout / 1000)};
|
||||||
auto ctestSettings = static_cast<CTestSettings *>(testBase()->testSettings());
|
auto ctestSettings = static_cast<CTestSettings *>(testBase()->testSettings());
|
||||||
options << ctestSettings->activeSettingsAsOptions();
|
options << ctestSettings->activeSettingsAsOptions();
|
||||||
Utils::CommandLine command = buildSystem->commandLineForTests(selected, options);
|
CommandLine command = buildSystem->commandLineForTests(selected, options);
|
||||||
if (command.executable().isEmpty())
|
if (command.executable().isEmpty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@@ -97,12 +99,12 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi
|
|||||||
config->setProject(project);
|
config->setProject(project);
|
||||||
config->setCommandLine(command);
|
config->setCommandLine(command);
|
||||||
const ProjectExplorer::RunConfiguration *runConfig = target->activeRunConfiguration();
|
const ProjectExplorer::RunConfiguration *runConfig = target->activeRunConfiguration();
|
||||||
Utils::Environment env = Utils::Environment::systemEnvironment();
|
Environment env = Environment::systemEnvironment();
|
||||||
if (QTC_GUARD(runConfig)) {
|
if (QTC_GUARD(runConfig)) {
|
||||||
if (auto envAspect = runConfig->aspect<ProjectExplorer::EnvironmentAspect>())
|
if (auto envAspect = runConfig->aspect<ProjectExplorer::EnvironmentAspect>())
|
||||||
env = envAspect->environment();
|
env = envAspect->environment();
|
||||||
}
|
}
|
||||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
if (HostOsInfo::isWindowsHost()) {
|
||||||
env.set("QT_FORCE_STDERR_LOGGING", "1");
|
env.set("QT_FORCE_STDERR_LOGGING", "1");
|
||||||
env.set("QT_LOGGING_TO_CONSOLE", "1");
|
env.set("QT_LOGGING_TO_CONSOLE", "1");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,13 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
TestOutputReader *GTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
TestOutputReader *GTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||||
Utils::QtcProcess *app) const
|
QtcProcess *app) const
|
||||||
{
|
{
|
||||||
return new GTestOutputReader(fi, app, buildDirectory(), projectFile());
|
return new GTestOutputReader(fi, app, buildDirectory(), projectFile());
|
||||||
}
|
}
|
||||||
@@ -88,13 +90,13 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Environment GTestConfiguration::filteredEnvironment(const Utils::Environment &original) const
|
Environment GTestConfiguration::filteredEnvironment(const Environment &original) const
|
||||||
{
|
{
|
||||||
const QStringList interfering{"GTEST_FILTER", "GTEST_ALSO_RUN_DISABLED_TESTS",
|
const QStringList interfering{"GTEST_FILTER", "GTEST_ALSO_RUN_DISABLED_TESTS",
|
||||||
"GTEST_REPEAT", "GTEST_SHUFFLE", "GTEST_RANDOM_SEED",
|
"GTEST_REPEAT", "GTEST_SHUFFLE", "GTEST_RANDOM_SEED",
|
||||||
"GTEST_OUTPUT", "GTEST_BREAK_ON_FAILURE", "GTEST_PRINT_TIME",
|
"GTEST_OUTPUT", "GTEST_BREAK_ON_FAILURE", "GTEST_PRINT_TIME",
|
||||||
"GTEST_CATCH_EXCEPTIONS"};
|
"GTEST_CATCH_EXCEPTIONS"};
|
||||||
Utils::Environment result = original;
|
Environment result = original;
|
||||||
if (!result.hasKey("GTEST_COLOR"))
|
if (!result.hasKey("GTEST_COLOR"))
|
||||||
result.set("GTEST_COLOR", "1"); // use colored output by default
|
result.set("GTEST_COLOR", "1"); // use colored output by default
|
||||||
for (const QString &key : interfering)
|
for (const QString &key : interfering)
|
||||||
|
|||||||
@@ -12,25 +12,27 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||||
Utils::QtcProcess *testApplication,
|
QtcProcess *testApplication,
|
||||||
const Utils::FilePath &buildDirectory,
|
const FilePath &buildDirectory,
|
||||||
const Utils::FilePath &projectFile)
|
const FilePath &projectFile)
|
||||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||||
, m_projectFile(projectFile)
|
, m_projectFile(projectFile)
|
||||||
{
|
{
|
||||||
if (m_testApplication) {
|
if (m_testApplication) {
|
||||||
connect(m_testApplication, &Utils::QtcProcess::done, this, [this] {
|
connect(m_testApplication, &QtcProcess::done, this, [this] {
|
||||||
const int exitCode = m_testApplication->exitCode();
|
const int exitCode = m_testApplication->exitCode();
|
||||||
if (exitCode == 1 && !m_description.isEmpty()) {
|
if (exitCode == 1 && !m_description.isEmpty()) {
|
||||||
createAndReportResult(Tr::tr("Running tests failed.\n %1\nExecutable: %2")
|
createAndReportResult(Tr::tr("Running tests failed.\n %1\nExecutable: %2")
|
||||||
.arg(m_description).arg(id()), ResultType::MessageFatal);
|
.arg(m_description).arg(id()), ResultType::MessageFatal);
|
||||||
}
|
}
|
||||||
// on Windows abort() will result in normal termination, but exit code will be set to 3
|
// on Windows abort() will result in normal termination, but exit code will be set to 3
|
||||||
if (Utils::HostOsInfo::isWindowsHost() && exitCode == 3)
|
if (HostOsInfo::isWindowsHost() && exitCode == 3)
|
||||||
reportCrash();
|
reportCrash();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -156,7 +158,7 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
|||||||
TestResult testResult = createDefaultResult();
|
TestResult testResult = createDefaultResult();
|
||||||
testResult.setResult(type);
|
testResult.setResult(type);
|
||||||
testResult.setLine(match.captured(3).toInt());
|
testResult.setLine(match.captured(3).toInt());
|
||||||
const Utils::FilePath file = constructSourceFilePath(m_buildDir, match.captured(2));
|
const FilePath file = constructSourceFilePath(m_buildDir, match.captured(2));
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
testResult.setFileName(file);
|
testResult.setFileName(file);
|
||||||
testResult.setDescription(match.captured(4));
|
testResult.setDescription(match.captured(4));
|
||||||
@@ -219,7 +221,7 @@ void GTestOutputReader::handleDescriptionAndReportResult(const TestResult &testR
|
|||||||
result = createDefaultResult();
|
result = createDefaultResult();
|
||||||
result.setResult(ResultType::MessageLocation);
|
result.setResult(ResultType::MessageLocation);
|
||||||
result.setLine(innerMatch.captured(2).toInt());
|
result.setLine(innerMatch.captured(2).toInt());
|
||||||
const Utils::FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
|
const FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
result.setFileName(file);
|
result.setFileName(file);
|
||||||
resultDescription << output;
|
resultDescription << output;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ static bool hasGTestNames(const CPlusPlus::Document::Ptr &document)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||||
const Utils::FilePath &fileName)
|
const FilePath &fileName)
|
||||||
{
|
{
|
||||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||||
if (doc.isNull() || !includesGTest(doc, m_cppSnapshot))
|
if (doc.isNull() || !includesGTest(doc, m_cppSnapshot))
|
||||||
@@ -93,10 +93,10 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureIn
|
|||||||
visitor.accept(ast);
|
visitor.accept(ast);
|
||||||
|
|
||||||
const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
||||||
Utils::FilePath proFile;
|
FilePath proFile;
|
||||||
const QList<CppEditor::ProjectPart::ConstPtr> &ppList = modelManager->projectPart(filePath);
|
const QList<CppEditor::ProjectPart::ConstPtr> &ppList = modelManager->projectPart(filePath);
|
||||||
if (!ppList.isEmpty())
|
if (!ppList.isEmpty())
|
||||||
proFile = Utils::FilePath::fromString(ppList.first()->projectFile);
|
proFile = FilePath::fromString(ppList.first()->projectFile);
|
||||||
else
|
else
|
||||||
return false; // happens if shutting down while parsing
|
return false; // happens if shutting down while parsing
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ GTestSettings::GTestSettings()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GTestSettingsPage::GTestSettingsPage(GTestSettings *settings, Utils::Id settingsId)
|
GTestSettingsPage::GTestSettingsPage(GTestSettings *settings, Id settingsId)
|
||||||
{
|
{
|
||||||
setId(settingsId);
|
setId(settingsId);
|
||||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -110,8 +112,8 @@ QVariant GTestTreeItem::data(int column, int role) const
|
|||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
if (type() == GroupNode
|
if (type() == GroupNode
|
||||||
&& GTestFramework::groupMode() == GTest::Constants::GTestFilter) {
|
&& GTestFramework::groupMode() == GTest::Constants::GTestFilter) {
|
||||||
static const QIcon filterIcon = Utils::Icon({{":/utils/images/filtericon.png",
|
static const QIcon filterIcon = Icon({{":/utils/images/filtericon.png",
|
||||||
Utils::Theme::PanelTextColorMid}}).icon();
|
Theme::PanelTextColorMid}}).icon();
|
||||||
return filterIcon;
|
return filterIcon;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -195,7 +197,7 @@ struct GTestCases
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void collectTestInfo(const GTestTreeItem *item,
|
static void collectTestInfo(const GTestTreeItem *item,
|
||||||
QHash<Utils::FilePath, GTestCases> &testCasesForProFile,
|
QHash<FilePath, GTestCases> &testCasesForProFile,
|
||||||
bool ignoreCheckState)
|
bool ignoreCheckState)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(item, return);
|
QTC_ASSERT(item, return);
|
||||||
@@ -210,7 +212,7 @@ static void collectTestInfo(const GTestTreeItem *item,
|
|||||||
QTC_ASSERT(childCount != 0, return);
|
QTC_ASSERT(childCount != 0, return);
|
||||||
QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return);
|
QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return);
|
||||||
if (ignoreCheckState || item->checked() == Qt::Checked) {
|
if (ignoreCheckState || item->checked() == Qt::Checked) {
|
||||||
const Utils::FilePath &projectFile = item->childItem(0)->proFile();
|
const FilePath &projectFile = item->childItem(0)->proFile();
|
||||||
testCasesForProFile[projectFile].filters.append(
|
testCasesForProFile[projectFile].filters.append(
|
||||||
gtestFilter(item->state()).arg(item->name()).arg('*'));
|
gtestFilter(item->state()).arg(item->name()).arg('*'));
|
||||||
testCasesForProFile[projectFile].testSetCount += childCount - 1;
|
testCasesForProFile[projectFile].testSetCount += childCount - 1;
|
||||||
@@ -229,7 +231,7 @@ static void collectTestInfo(const GTestTreeItem *item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void collectFailedTestInfo(const GTestTreeItem *item,
|
static void collectFailedTestInfo(const GTestTreeItem *item,
|
||||||
QHash<Utils::FilePath, GTestCases> &testCasesForProfile)
|
QHash<FilePath, GTestCases> &testCasesForProfile)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(item, return);
|
QTC_ASSERT(item, return);
|
||||||
QTC_ASSERT(item->type() == TestTreeItem::Root, return);
|
QTC_ASSERT(item->type() == TestTreeItem::Root, return);
|
||||||
@@ -254,7 +256,7 @@ QList<ITestConfiguration *> GTestTreeItem::getTestConfigurations(bool ignoreChec
|
|||||||
if (!project || type() != Root)
|
if (!project || type() != Root)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QHash<Utils::FilePath, GTestCases> testCasesForProFile;
|
QHash<FilePath, GTestCases> testCasesForProFile;
|
||||||
for (int row = 0, count = childCount(); row < count; ++row) {
|
for (int row = 0, count = childCount(); row < count; ++row) {
|
||||||
auto child = static_cast<const GTestTreeItem *>(childAt(row));
|
auto child = static_cast<const GTestTreeItem *>(childAt(row));
|
||||||
collectTestInfo(child, testCasesForProFile, ignoreCheckState);
|
collectTestInfo(child, testCasesForProFile, ignoreCheckState);
|
||||||
@@ -293,7 +295,7 @@ QList<ITestConfiguration *> GTestTreeItem::getFailedTestConfigurations() const
|
|||||||
if (!project || type() != Root)
|
if (!project || type() != Root)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QHash<Utils::FilePath, GTestCases> testCasesForProFile;
|
QHash<FilePath, GTestCases> testCasesForProFile;
|
||||||
collectFailedTestInfo(this, testCasesForProFile);
|
collectFailedTestInfo(this, testCasesForProFile);
|
||||||
|
|
||||||
for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) {
|
for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) {
|
||||||
@@ -311,14 +313,14 @@ QList<ITestConfiguration *> GTestTreeItem::getFailedTestConfigurations() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ITestConfiguration *> GTestTreeItem::getTestConfigurationsForFile(const Utils::FilePath &fileName) const
|
QList<ITestConfiguration *> GTestTreeItem::getTestConfigurationsForFile(const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
QList<ITestConfiguration *> result;
|
QList<ITestConfiguration *> result;
|
||||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
||||||
if (!project || type() != Root)
|
if (!project || type() != Root)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QHash<Utils::FilePath, GTestCases> testCases;
|
QHash<FilePath, GTestCases> testCases;
|
||||||
forAllChildItems([&testCases, &fileName](TestTreeItem *node) {
|
forAllChildItems([&testCases, &fileName](TestTreeItem *node) {
|
||||||
if (node->type() == Type::TestCase && node->filePath() == fileName) {
|
if (node->type() == Type::TestCase && node->filePath() == fileName) {
|
||||||
QTC_ASSERT(node->parentItem(), return);
|
QTC_ASSERT(node->parentItem(), return);
|
||||||
@@ -358,7 +360,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
|
|||||||
case Root:
|
case Root:
|
||||||
if (result->framework->grouping()) {
|
if (result->framework->grouping()) {
|
||||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||||
const Utils::FilePath base = parseResult->fileName.absolutePath();
|
const FilePath base = parseResult->fileName.absolutePath();
|
||||||
for (int row = 0; row < childCount(); ++row) {
|
for (int row = 0; row < childCount(); ++row) {
|
||||||
GTestTreeItem *group = static_cast<GTestTreeItem *>(childAt(row));
|
GTestTreeItem *group = static_cast<GTestTreeItem *>(childAt(row));
|
||||||
if (group->filePath() != base.absoluteFilePath())
|
if (group->filePath() != base.absoluteFilePath())
|
||||||
@@ -442,7 +444,7 @@ bool GTestTreeItem::modify(const TestParseResult *result)
|
|||||||
TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
||||||
{
|
{
|
||||||
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
if (GTestFramework::groupMode() == GTest::Constants::Directory) {
|
||||||
const Utils::FilePath &absPath = filePath().absolutePath();
|
const FilePath &absPath = filePath().absolutePath();
|
||||||
return new GTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
return new GTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
||||||
} else { // GTestFilter
|
} else { // GTestFilter
|
||||||
QTC_ASSERT(childCount(), return nullptr); // paranoia
|
QTC_ASSERT(childCount(), return nullptr); // paranoia
|
||||||
@@ -453,7 +455,7 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const
|
|||||||
matchesFilter(activeFilter, fullTestName) ? matchingString() : notMatchingString();
|
matchesFilter(activeFilter, fullTestName) ? matchingString() : notMatchingString();
|
||||||
// FIXME activeFilter is not a FilePath
|
// FIXME activeFilter is not a FilePath
|
||||||
auto groupNode = new GTestTreeItem(framework(), groupNodeName,
|
auto groupNode = new GTestTreeItem(framework(), groupNodeName,
|
||||||
Utils::FilePath::fromString(activeFilter),
|
FilePath::fromString(activeFilter),
|
||||||
TestTreeItem::GroupNode);
|
TestTreeItem::GroupNode);
|
||||||
if (groupNodeName == notMatchingString())
|
if (groupNodeName == notMatchingString())
|
||||||
groupNode->setData(0, Qt::Unchecked, Qt::CheckStateRole);
|
groupNode->setData(0, Qt::Unchecked, Qt::CheckStateRole);
|
||||||
@@ -475,7 +477,7 @@ bool GTestTreeItem::modifyTestSetContent(const GTestParseResult *result)
|
|||||||
|
|
||||||
TestTreeItem *GTestTreeItem::findChildByNameStateAndFile(const QString &name,
|
TestTreeItem *GTestTreeItem::findChildByNameStateAndFile(const QString &name,
|
||||||
GTestTreeItem::TestStates state,
|
GTestTreeItem::TestStates state,
|
||||||
const Utils::FilePath &proFile) const
|
const FilePath &proFile) const
|
||||||
{
|
{
|
||||||
return findFirstLevelChildItem([name, state, proFile](const TestTreeItem *other) {
|
return findFirstLevelChildItem([name, state, proFile](const TestTreeItem *other) {
|
||||||
const GTestTreeItem *gtestItem = static_cast<const GTestTreeItem *>(other);
|
const GTestTreeItem *gtestItem = static_cast<const GTestTreeItem *>(other);
|
||||||
@@ -504,13 +506,13 @@ QSet<QString> internalTargets(const TestTreeItem &item)
|
|||||||
const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject());
|
const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject());
|
||||||
if (!projectInfo)
|
if (!projectInfo)
|
||||||
return {};
|
return {};
|
||||||
const Utils::FilePath filePath = item.filePath();
|
const FilePath filePath = item.filePath();
|
||||||
const QVector<CppEditor::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
const QVector<CppEditor::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
||||||
if (projectParts.isEmpty())
|
if (projectParts.isEmpty())
|
||||||
return cppMM->dependingInternalTargets(item.filePath());
|
return cppMM->dependingInternalTargets(item.filePath());
|
||||||
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) {
|
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||||
if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile()
|
if (FilePath::fromString(projectPart->projectFile) == item.proFile()
|
||||||
&& Utils::anyOf(projectPart->files, [&filePath] (const CppEditor::ProjectFile &pf) {
|
&& Utils::anyOf(projectPart->files, [&filePath](const CppEditor::ProjectFile &pf) {
|
||||||
return pf.path == filePath;
|
return pf.path == filePath;
|
||||||
})) {
|
})) {
|
||||||
result.insert(projectPart->buildSystemTarget);
|
result.insert(projectPart->buildSystemTarget);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "testtreeitem.h"
|
#include "testtreeitem.h"
|
||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
|
|
||||||
ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type)
|
ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type)
|
||||||
@@ -15,15 +17,15 @@ ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type)
|
|||||||
, m_type(type)
|
, m_type(type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Utils::Id ITestBase::settingsId() const
|
Id ITestBase::settingsId() const
|
||||||
{
|
{
|
||||||
return Utils::Id(Constants::SETTINGSPAGE_PREFIX)
|
return Id(Constants::SETTINGSPAGE_PREFIX)
|
||||||
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Id ITestBase::id() const
|
Id ITestBase::id() const
|
||||||
{
|
{
|
||||||
return Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
|
return Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITestBase::resetRootNode()
|
void ITestBase::resetRootNode()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ CppParser::CppParser(ITestFramework *framework)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
void CppParser::init(const FilePaths &filesToParse, bool fullParse)
|
||||||
{
|
{
|
||||||
Q_UNUSED(filesToParse)
|
Q_UNUSED(filesToParse)
|
||||||
Q_UNUSED(fullParse)
|
Q_UNUSED(fullParse)
|
||||||
@@ -32,7 +32,7 @@ void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
|||||||
m_workingCopy = CppEditor::CppModelManager::instance()->workingCopy();
|
m_workingCopy = CppEditor::CppModelManager::instance()->workingCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppParser::selectedForBuilding(const Utils::FilePath &fileName)
|
bool CppParser::selectedForBuilding(const FilePath &fileName)
|
||||||
{
|
{
|
||||||
QList<CppEditor::ProjectPart::ConstPtr> projParts =
|
QList<CppEditor::ProjectPart::ConstPtr> projParts =
|
||||||
CppEditor::CppModelManager::instance()->projectPart(fileName);
|
CppEditor::CppModelManager::instance()->projectPart(fileName);
|
||||||
@@ -40,7 +40,7 @@ bool CppParser::selectedForBuilding(const Utils::FilePath &fileName)
|
|||||||
return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding;
|
return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const
|
QByteArray CppParser::getFileContent(const FilePath &filePath) const
|
||||||
{
|
{
|
||||||
QByteArray fileContent;
|
QByteArray fileContent;
|
||||||
if (m_workingCopy.contains(filePath)) {
|
if (m_workingCopy.contains(filePath)) {
|
||||||
@@ -48,8 +48,8 @@ QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const
|
|||||||
} else {
|
} else {
|
||||||
QString error;
|
QString error;
|
||||||
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
||||||
if (Utils::TextFileFormat::readFileUTF8(filePath, codec, &fileContent, &error)
|
if (TextFileFormat::readFileUTF8(filePath, codec, &fileContent, &error)
|
||||||
!= Utils::TextFileFormat::ReadSuccess) {
|
!= TextFileFormat::ReadSuccess) {
|
||||||
qDebug() << "Failed to read file" << filePath << ":" << error;
|
qDebug() << "Failed to read file" << filePath << ":" << error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||||
const Utils::FilePath &filePath,
|
const FilePath &filePath,
|
||||||
const QString &cacheString,
|
const QString &cacheString,
|
||||||
const std::function<bool(const FilePath &)> &checker)
|
const std::function<bool(const FilePath &)> &checker)
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@ bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||||
const Utils::FilePath &filePath,
|
const FilePath &filePath,
|
||||||
const QString &headerFilePath)
|
const QString &headerFilePath)
|
||||||
{
|
{
|
||||||
return Autotest::precompiledHeaderContains(snapshot,
|
return Autotest::precompiledHeaderContains(snapshot,
|
||||||
@@ -94,7 +94,7 @@ bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
||||||
const Utils::FilePath &filePath,
|
const FilePath &filePath,
|
||||||
const QRegularExpression &headerFileRegex)
|
const QRegularExpression &headerFileRegex)
|
||||||
{
|
{
|
||||||
return Autotest::precompiledHeaderContains(snapshot,
|
return Autotest::precompiledHeaderContains(snapshot,
|
||||||
@@ -113,7 +113,7 @@ void CppParser::release()
|
|||||||
s_pchLookupCache.clear();
|
s_pchLookupCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlusPlus::Document::Ptr CppParser::document(const Utils::FilePath &fileName)
|
CPlusPlus::Document::Ptr CppParser::document(const FilePath &fileName)
|
||||||
{
|
{
|
||||||
return selectedForBuilding(fileName) ? m_cppSnapshot.document(fileName) : nullptr;
|
return selectedForBuilding(fileName) ? m_cppSnapshot.document(fileName) : nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <QByteArrayList>
|
#include <QByteArrayList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
namespace QTestUtils {
|
namespace QTestUtils {
|
||||||
@@ -25,10 +27,9 @@ bool isQTestMacro(const QByteArray ¯o)
|
|||||||
return valid.contains(macro);
|
return valid.contains(macro);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<Utils::FilePath, TestCases> testCaseNamesForFiles(ITestFramework *framework,
|
QHash<FilePath, TestCases> testCaseNamesForFiles(ITestFramework *framework, const FilePaths &files)
|
||||||
const Utils::FilePaths &files)
|
|
||||||
{
|
{
|
||||||
QHash<Utils::FilePath, TestCases> result;
|
QHash<FilePath, TestCases> result;
|
||||||
TestTreeItem *rootNode = framework->rootNode();
|
TestTreeItem *rootNode = framework->rootNode();
|
||||||
QTC_ASSERT(rootNode, return result);
|
QTC_ASSERT(rootNode, return result);
|
||||||
|
|
||||||
@@ -48,18 +49,17 @@ QHash<Utils::FilePath, TestCases> testCaseNamesForFiles(ITestFramework *framewor
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMultiHash<Utils::FilePath, Utils::FilePath> alternativeFiles(ITestFramework *framework,
|
QMultiHash<FilePath, FilePath> alternativeFiles(ITestFramework *framework, const FilePaths &files)
|
||||||
const Utils::FilePaths &files)
|
|
||||||
{
|
{
|
||||||
QMultiHash<Utils::FilePath, Utils::FilePath> result;
|
QMultiHash<FilePath, FilePath> result;
|
||||||
TestTreeItem *rootNode = framework->rootNode();
|
TestTreeItem *rootNode = framework->rootNode();
|
||||||
QTC_ASSERT(rootNode, return result);
|
QTC_ASSERT(rootNode, return result);
|
||||||
|
|
||||||
rootNode->forFirstLevelChildren([&result, &files](ITestTreeItem *child) {
|
rootNode->forFirstLevelChildren([&result, &files](ITestTreeItem *child) {
|
||||||
const Utils::FilePath &baseFilePath = child->filePath();
|
const FilePath &baseFilePath = child->filePath();
|
||||||
for (int childRow = 0, count = child->childCount(); childRow < count; ++childRow) {
|
for (int childRow = 0, count = child->childCount(); childRow < count; ++childRow) {
|
||||||
auto grandChild = static_cast<const QtTestTreeItem *>(child->childAt(childRow));
|
auto grandChild = static_cast<const QtTestTreeItem *>(child->childAt(childRow));
|
||||||
const Utils::FilePath &filePath = grandChild->filePath();
|
const FilePath &filePath = grandChild->filePath();
|
||||||
if (grandChild->inherited() && baseFilePath != filePath && files.contains(filePath)) {
|
if (grandChild->inherited() && baseFilePath != filePath && files.contains(filePath)) {
|
||||||
if (!result.contains(filePath, baseFilePath))
|
if (!result.contains(filePath, baseFilePath))
|
||||||
result.insert(filePath, baseFilePath);
|
result.insert(filePath, baseFilePath);
|
||||||
@@ -128,10 +128,10 @@ QStringList filterInterfering(const QStringList &provided, QStringList *omitted,
|
|||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Environment prepareBasicEnvironment(const Utils::Environment &env)
|
Environment prepareBasicEnvironment(const Environment &env)
|
||||||
{
|
{
|
||||||
Utils::Environment result(env);
|
Environment result(env);
|
||||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
if (HostOsInfo::isWindowsHost()) {
|
||||||
result.set("QT_FORCE_STDERR_LOGGING", "1");
|
result.set("QT_FORCE_STDERR_LOGGING", "1");
|
||||||
result.set("QT_LOGGING_TO_CONSOLE", "1");
|
result.set("QT_LOGGING_TO_CONSOLE", "1");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -27,7 +29,7 @@ static QStringList quoteIfNeeded(const QStringList &testCases, bool debugMode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestOutputReader *QtTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
TestOutputReader *QtTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||||
Utils::QtcProcess *app) const
|
QtcProcess *app) const
|
||||||
{
|
{
|
||||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||||
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
||||||
@@ -71,7 +73,7 @@ QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) co
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Environment QtTestConfiguration::filteredEnvironment(const Utils::Environment &original) const
|
Environment QtTestConfiguration::filteredEnvironment(const Environment &original) const
|
||||||
{
|
{
|
||||||
return QTestUtils::prepareBasicEnvironment(original);
|
return QTestUtils::prepareBasicEnvironment(original);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -104,9 +106,9 @@ static QString constructBenchmarkInformation(const QString &metric, double value
|
|||||||
}
|
}
|
||||||
|
|
||||||
QtTestOutputReader::QtTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
QtTestOutputReader::QtTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||||
Utils::QtcProcess *testApplication,
|
QtcProcess *testApplication,
|
||||||
const Utils::FilePath &buildDirectory,
|
const FilePath &buildDirectory,
|
||||||
const Utils::FilePath &projectFile,
|
const FilePath &projectFile,
|
||||||
OutputMode mode, TestType type)
|
OutputMode mode, TestType type)
|
||||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||||
, m_projectFile(projectFile)
|
, m_projectFile(projectFile)
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ TestTreeItem *QtTestParseResult::createTestTreeItem() const
|
|||||||
|
|
||||||
static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot)
|
static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot)
|
||||||
{
|
{
|
||||||
static QStringList expectedHeaderPrefixes
|
static QStringList expectedHeaderPrefixes = HostOsInfo::isMacHost()
|
||||||
= Utils::HostOsInfo::isMacHost()
|
|
||||||
? QStringList({"QtTest.framework/Headers", "QtTest"}) : QStringList({"QtTest"});
|
? QStringList({"QtTest.framework/Headers", "QtTest"}) : QStringList({"QtTest"});
|
||||||
|
|
||||||
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
|
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
|
||||||
@@ -71,7 +70,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool qtTestLibDefined(const Utils::FilePath &fileName)
|
static bool qtTestLibDefined(const FilePath &fileName)
|
||||||
{
|
{
|
||||||
const QList<CppEditor::ProjectPart::ConstPtr> parts =
|
const QList<CppEditor::ProjectPart::ConstPtr> parts =
|
||||||
CppEditor::CppModelManager::instance()->projectPart(fileName);
|
CppEditor::CppModelManager::instance()->projectPart(fileName);
|
||||||
@@ -84,7 +83,7 @@ static bool qtTestLibDefined(const Utils::FilePath &fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestCases QtTestParser::testCases(const CppEditor::CppModelManager *modelManager,
|
TestCases QtTestParser::testCases(const CppEditor::CppModelManager *modelManager,
|
||||||
const Utils::FilePath &filePath) const
|
const FilePath &filePath) const
|
||||||
{
|
{
|
||||||
const QByteArray &fileContent = getFileContent(filePath);
|
const QByteArray &fileContent = getFileContent(filePath);
|
||||||
CPlusPlus::Document::Ptr document = modelManager->document(filePath);
|
CPlusPlus::Document::Ptr document = modelManager->document(filePath);
|
||||||
@@ -141,7 +140,7 @@ TestCases QtTestParser::testCases(const CppEditor::CppModelManager *modelManager
|
|||||||
static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc,
|
static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc,
|
||||||
const CPlusPlus::Snapshot &snapshot,
|
const CPlusPlus::Snapshot &snapshot,
|
||||||
const QString &testCaseName,
|
const QString &testCaseName,
|
||||||
const Utils::FilePaths &alternativeFiles = {},
|
const FilePaths &alternativeFiles = {},
|
||||||
int *line = nullptr,
|
int *line = nullptr,
|
||||||
int *column = nullptr)
|
int *column = nullptr)
|
||||||
{
|
{
|
||||||
@@ -153,7 +152,7 @@ static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc,
|
|||||||
doc->globalNamespace());
|
doc->globalNamespace());
|
||||||
// fallback for inherited functions
|
// fallback for inherited functions
|
||||||
if (lookupItems.size() == 0 && !alternativeFiles.isEmpty()) {
|
if (lookupItems.size() == 0 && !alternativeFiles.isEmpty()) {
|
||||||
for (const Utils::FilePath &alternativeFile : alternativeFiles) {
|
for (const FilePath &alternativeFile : alternativeFiles) {
|
||||||
if (snapshot.contains(alternativeFile)) {
|
if (snapshot.contains(alternativeFile)) {
|
||||||
CPlusPlus::Document::Ptr document = snapshot.document(alternativeFile);
|
CPlusPlus::Document::Ptr document = snapshot.document(alternativeFile);
|
||||||
CPlusPlus::TypeOfExpression typeOfExpr; // we need a new one with no bindings
|
CPlusPlus::TypeOfExpression typeOfExpr; // we need a new one with no bindings
|
||||||
@@ -179,10 +178,10 @@ static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc,
|
|||||||
return declaringDoc;
|
return declaringDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QSet<Utils::FilePath> filesWithDataFunctionDefinitions(
|
static QSet<FilePath> filesWithDataFunctionDefinitions(
|
||||||
const QMap<QString, QtTestCodeLocationAndType> &testFunctions)
|
const QMap<QString, QtTestCodeLocationAndType> &testFunctions)
|
||||||
{
|
{
|
||||||
QSet<Utils::FilePath> result;
|
QSet<FilePath> result;
|
||||||
QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = testFunctions.begin();
|
QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = testFunctions.begin();
|
||||||
const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = testFunctions.end();
|
const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = testFunctions.end();
|
||||||
|
|
||||||
@@ -195,7 +194,7 @@ static QSet<Utils::FilePath> filesWithDataFunctionDefinitions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, QtTestCodeLocationList> QtTestParser::checkForDataTags(
|
QHash<QString, QtTestCodeLocationList> QtTestParser::checkForDataTags(
|
||||||
const Utils::FilePath &fileName) const
|
const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
const QByteArray fileContent = getFileContent(fileName);
|
const QByteArray fileContent = getFileContent(fileName);
|
||||||
CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName);
|
CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName);
|
||||||
@@ -289,12 +288,12 @@ static QtTestCodeLocationList tagLocationsFor(const QtTestParseResult *func,
|
|||||||
static bool isQObject(const CPlusPlus::Document::Ptr &declaringDoc)
|
static bool isQObject(const CPlusPlus::Document::Ptr &declaringDoc)
|
||||||
{
|
{
|
||||||
const FilePath file = declaringDoc->filePath();
|
const FilePath file = declaringDoc->filePath();
|
||||||
return (Utils::HostOsInfo::isMacHost() && file.endsWith("QtCore.framework/Headers/qobject.h"))
|
return (HostOsInfo::isMacHost() && file.endsWith("QtCore.framework/Headers/qobject.h"))
|
||||||
|| file.endsWith("QtCore/qobject.h") || file.endsWith("kernel/qobject.h");
|
|| file.endsWith("QtCore/qobject.h") || file.endsWith("kernel/qobject.h");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||||
const Utils::FilePath &fileName)
|
const FilePath &fileName)
|
||||||
{
|
{
|
||||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||||
if (doc.isNull())
|
if (doc.isNull())
|
||||||
@@ -359,8 +358,8 @@ std::optional<bool> QtTestParser::fillTestCaseData(
|
|||||||
if (data.testFunctions.isEmpty() && testCaseName == "QObject" && isQObject(declaringDoc))
|
if (data.testFunctions.isEmpty() && testCaseName == "QObject" && isQObject(declaringDoc))
|
||||||
return true; // we did not handle it, but we do not expect any test defined there either
|
return true; // we did not handle it, but we do not expect any test defined there either
|
||||||
|
|
||||||
const QSet<Utils::FilePath> &files = filesWithDataFunctionDefinitions(data.testFunctions);
|
const QSet<FilePath> &files = filesWithDataFunctionDefinitions(data.testFunctions);
|
||||||
for (const Utils::FilePath &file : files)
|
for (const FilePath &file : files)
|
||||||
Utils::addToHash(&(data.dataTags), checkForDataTags(file));
|
Utils::addToHash(&(data.dataTags), checkForDataTags(file));
|
||||||
|
|
||||||
data.fileName = declaringDoc->filePath();
|
data.fileName = declaringDoc->filePath();
|
||||||
@@ -378,7 +377,7 @@ QtTestParseResult *QtTestParser::createParseResult(
|
|||||||
parseResult->displayName = testCaseName;
|
parseResult->displayName = testCaseName;
|
||||||
parseResult->line = data.line;
|
parseResult->line = data.line;
|
||||||
parseResult->column = data.column;
|
parseResult->column = data.column;
|
||||||
parseResult->proFile = Utils::FilePath::fromString(projectFile);
|
parseResult->proFile = FilePath::fromString(projectFile);
|
||||||
parseResult->setRunsMultipleTestcases(data.multipleTestCases);
|
parseResult->setRunsMultipleTestcases(data.multipleTestCases);
|
||||||
QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = data.testFunctions.begin();
|
QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = data.testFunctions.begin();
|
||||||
const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = data.testFunctions.end();
|
const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = data.testFunctions.end();
|
||||||
@@ -414,7 +413,7 @@ QtTestParseResult *QtTestParser::createParseResult(
|
|||||||
return parseResult;
|
return parseResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
void QtTestParser::init(const FilePaths &filesToParse, bool fullParse)
|
||||||
{
|
{
|
||||||
if (!fullParse) { // in a full parse cached information might lead to wrong results
|
if (!fullParse) { // in a full parse cached information might lead to wrong results
|
||||||
m_testCases = QTestUtils::testCaseNamesForFiles(framework(), filesToParse);
|
m_testCases = QTestUtils::testCaseNamesForFiles(framework(), filesToParse);
|
||||||
|
|||||||
@@ -12,11 +12,13 @@
|
|||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QtTestTreeItem::QtTestTreeItem(ITestFramework *testFramework, const QString &name,
|
QtTestTreeItem::QtTestTreeItem(ITestFramework *testFramework, const QString &name,
|
||||||
const Utils::FilePath &filePath, TestTreeItem::Type type)
|
const FilePath &filePath, TestTreeItem::Type type)
|
||||||
: TestTreeItem(testFramework, name, filePath, type)
|
: TestTreeItem(testFramework, name, filePath, type)
|
||||||
{
|
{
|
||||||
if (type == TestDataTag)
|
if (type == TestDataTag)
|
||||||
@@ -286,7 +288,7 @@ QList<ITestConfiguration *> QtTestTreeItem::getFailedTestConfigurations() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ITestConfiguration *> QtTestTreeItem::getTestConfigurationsForFile(const Utils::FilePath &fileName) const
|
QList<ITestConfiguration *> QtTestTreeItem::getTestConfigurationsForFile(const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
QList<ITestConfiguration *> result;
|
QList<ITestConfiguration *> result;
|
||||||
|
|
||||||
@@ -321,7 +323,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result)
|
|||||||
switch (type()) {
|
switch (type()) {
|
||||||
case Root:
|
case Root:
|
||||||
if (result->framework->grouping()) {
|
if (result->framework->grouping()) {
|
||||||
const Utils::FilePath path = result->fileName.absolutePath();
|
const FilePath path = result->fileName.absolutePath();
|
||||||
for (int row = 0; row < childCount(); ++row) {
|
for (int row = 0; row < childCount(); ++row) {
|
||||||
TestTreeItem *group = childItem(row);
|
TestTreeItem *group = childItem(row);
|
||||||
if (group->filePath() != path)
|
if (group->filePath() != path)
|
||||||
@@ -394,7 +396,7 @@ bool QtTestTreeItem::modify(const TestParseResult *result)
|
|||||||
|
|
||||||
TestTreeItem *QtTestTreeItem::createParentGroupNode() const
|
TestTreeItem *QtTestTreeItem::createParentGroupNode() const
|
||||||
{
|
{
|
||||||
const Utils::FilePath &absPath = filePath().absolutePath();
|
const FilePath &absPath = filePath().absolutePath();
|
||||||
return new QtTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
return new QtTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +405,7 @@ bool QtTestTreeItem::isGroupable() const
|
|||||||
return type() == TestCase;
|
return type() == TestCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTreeItem *QtTestTreeItem::findChildByFileNameAndType(const Utils::FilePath &file,
|
TestTreeItem *QtTestTreeItem::findChildByFileNameAndType(const FilePath &file,
|
||||||
const QString &name, Type type) const
|
const QString &name, Type type) const
|
||||||
{
|
{
|
||||||
return findFirstLevelChildItem([file, name, type](const TestTreeItem *other) {
|
return findFirstLevelChildItem([file, name, type](const TestTreeItem *other) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -36,7 +37,7 @@ bool TestVisitor::visit(Class *symbol)
|
|||||||
Symbol *member = symbol->memberAt(i);
|
Symbol *member = symbol->memberAt(i);
|
||||||
Type *type = member->type().type();
|
Type *type = member->type().type();
|
||||||
|
|
||||||
const QString className = o.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(
|
const QString className = o.prettyName(LookupContext::fullyQualifiedName(
|
||||||
member->enclosingClass()));
|
member->enclosingClass()));
|
||||||
if (className != m_className)
|
if (className != m_className)
|
||||||
continue;
|
continue;
|
||||||
@@ -51,12 +52,12 @@ bool TestVisitor::visit(Class *symbol)
|
|||||||
Function *functionDefinition = m_symbolFinder.findMatchingDefinition(
|
Function *functionDefinition = m_symbolFinder.findMatchingDefinition(
|
||||||
func, m_snapshot, true);
|
func, m_snapshot, true);
|
||||||
if (functionDefinition && functionDefinition->fileId()) {
|
if (functionDefinition && functionDefinition->fileId()) {
|
||||||
locationAndType.m_filePath = Utils::FilePath::fromString(
|
locationAndType.m_filePath = FilePath::fromString(
|
||||||
QString::fromUtf8(functionDefinition->fileName()));
|
QString::fromUtf8(functionDefinition->fileName()));
|
||||||
locationAndType.m_line = functionDefinition->line();
|
locationAndType.m_line = functionDefinition->line();
|
||||||
locationAndType.m_column = functionDefinition->column() - 1;
|
locationAndType.m_column = functionDefinition->column() - 1;
|
||||||
} else { // if we cannot find the definition use declaration as fallback
|
} else { // if we cannot find the definition use declaration as fallback
|
||||||
locationAndType.m_filePath = Utils::FilePath::fromString(
|
locationAndType.m_filePath = FilePath::fromString(
|
||||||
QString::fromUtf8(member->fileName()));
|
QString::fromUtf8(member->fileName()));
|
||||||
locationAndType.m_line = member->line();
|
locationAndType.m_line = member->line();
|
||||||
locationAndType.m_column = member->column() - 1;
|
locationAndType.m_column = member->column() - 1;
|
||||||
@@ -74,7 +75,7 @@ bool TestVisitor::visit(Class *symbol)
|
|||||||
}
|
}
|
||||||
for (int counter = 0, end = symbol->baseClassCount(); counter < end; ++counter) {
|
for (int counter = 0, end = symbol->baseClassCount(); counter < end; ++counter) {
|
||||||
if (BaseClass *base = symbol->baseClassAt(counter)) {
|
if (BaseClass *base = symbol->baseClassAt(counter)) {
|
||||||
const QString &baseClassName = o.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(base));
|
const QString &baseClassName = o.prettyName(LookupContext::fullyQualifiedName(base));
|
||||||
if (baseClassName != "QObject")
|
if (baseClassName != "QObject")
|
||||||
m_baseClasses.insert(baseClassName);
|
m_baseClasses.insert(baseClassName);
|
||||||
}
|
}
|
||||||
@@ -171,7 +172,7 @@ bool TestDataFunctionVisitor::visit(FunctionDefinitionAST *ast)
|
|||||||
|
|
||||||
LookupContext lc;
|
LookupContext lc;
|
||||||
const QString prettyName =
|
const QString prettyName =
|
||||||
m_overview.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(ast->symbol));
|
m_overview.prettyName(LookupContext::fullyQualifiedName(ast->symbol));
|
||||||
// do not handle functions that aren't real test data functions
|
// do not handle functions that aren't real test data functions
|
||||||
if (!prettyName.endsWith("_data"))
|
if (!prettyName.endsWith("_data"))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include <QByteArrayList>
|
#include <QByteArrayList>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
namespace QuickTestUtils {
|
namespace QuickTestUtils {
|
||||||
@@ -20,10 +22,9 @@ bool isQuickTestMacro(const QByteArray ¯o)
|
|||||||
return valid.contains(macro);
|
return valid.contains(macro);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<Utils::FilePath, Utils::FilePath> proFilesForQmlFiles(ITestFramework *framework,
|
QHash<FilePath, FilePath> proFilesForQmlFiles(ITestFramework *framework, const FilePaths &files)
|
||||||
const Utils::FilePaths &files)
|
|
||||||
{
|
{
|
||||||
QHash<Utils::FilePath, Utils::FilePath> result;
|
QHash<FilePath, FilePath> result;
|
||||||
TestTreeItem *rootNode = framework->rootNode();
|
TestTreeItem *rootNode = framework->rootNode();
|
||||||
QTC_ASSERT(rootNode, return result);
|
QTC_ASSERT(rootNode, return result);
|
||||||
|
|
||||||
@@ -31,16 +32,16 @@ QHash<Utils::FilePath, Utils::FilePath> proFilesForQmlFiles(ITestFramework *fram
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
rootNode->forFirstLevelChildItems([&result, &files](TestTreeItem *child) {
|
rootNode->forFirstLevelChildItems([&result, &files](TestTreeItem *child) {
|
||||||
const Utils::FilePath &file = child->filePath();
|
const FilePath &file = child->filePath();
|
||||||
if (!file.isEmpty() && files.contains(file)) {
|
if (!file.isEmpty() && files.contains(file)) {
|
||||||
const Utils::FilePath &proFile = child->proFile();
|
const FilePath &proFile = child->proFile();
|
||||||
if (!proFile.isEmpty())
|
if (!proFile.isEmpty())
|
||||||
result.insert(file, proFile);
|
result.insert(file, proFile);
|
||||||
}
|
}
|
||||||
child->forFirstLevelChildItems([&result, &files](TestTreeItem *grandChild) {
|
child->forFirstLevelChildItems([&result, &files](TestTreeItem *grandChild) {
|
||||||
const Utils::FilePath &file = grandChild->filePath();
|
const FilePath &file = grandChild->filePath();
|
||||||
if (!file.isEmpty() && files.contains(file)) {
|
if (!file.isEmpty() && files.contains(file)) {
|
||||||
const Utils::FilePath &proFile = grandChild->proFile();
|
const FilePath &proFile = grandChild->proFile();
|
||||||
if (!proFile.isEmpty())
|
if (!proFile.isEmpty())
|
||||||
result.insert(file, proFile);
|
result.insert(file, proFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ QuickTestConfiguration::QuickTestConfiguration(ITestFramework *framework)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestOutputReader *QuickTestConfiguration::createOutputReader(
|
TestOutputReader *QuickTestConfiguration::createOutputReader(
|
||||||
const QFutureInterface<TestResult> &fi, Utils::QtcProcess *app) const
|
const QFutureInterface<TestResult> &fi, QtcProcess *app) const
|
||||||
{
|
{
|
||||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||||
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
||||||
@@ -64,7 +66,7 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted)
|
|||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Environment QuickTestConfiguration::filteredEnvironment(const Utils::Environment &original) const
|
Environment QuickTestConfiguration::filteredEnvironment(const Environment &original) const
|
||||||
{
|
{
|
||||||
return QTestUtils::prepareBasicEnvironment(original);
|
return QTestUtils::prepareBasicEnvironment(original);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ TestTreeItem *QuickTestParseResult::createTestTreeItem() const
|
|||||||
static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
||||||
const CPlusPlus::Snapshot &snapshot)
|
const CPlusPlus::Snapshot &snapshot)
|
||||||
{
|
{
|
||||||
static QStringList expectedHeaderPrefixes
|
static QStringList expectedHeaderPrefixes = HostOsInfo::isMacHost()
|
||||||
= Utils::HostOsInfo::isMacHost()
|
|
||||||
? QStringList({"QtQuickTest.framework/Headers", "QtQuickTest"})
|
? QStringList({"QtQuickTest.framework/Headers", "QtQuickTest"})
|
||||||
: QStringList({"QtQuickTest"});
|
: QStringList({"QtQuickTest"});
|
||||||
|
|
||||||
@@ -78,8 +77,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM,
|
static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM, const FilePath &fileName)
|
||||||
const Utils::FilePath &fileName)
|
|
||||||
{
|
{
|
||||||
const QList<CppEditor::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName);
|
const QList<CppEditor::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName);
|
||||||
if (parts.size() > 0) {
|
if (parts.size() > 0) {
|
||||||
@@ -103,7 +101,7 @@ static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM,
|
|||||||
QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const
|
QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const
|
||||||
{
|
{
|
||||||
const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses();
|
const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses();
|
||||||
const Utils::FilePath filePath = doc->filePath();
|
const FilePath filePath = doc->filePath();
|
||||||
|
|
||||||
for (const CPlusPlus::Document::MacroUse ¯o : macros) {
|
for (const CPlusPlus::Document::MacroUse ¯o : macros) {
|
||||||
if (!macro.isFunctionLike() || macro.arguments().isEmpty())
|
if (!macro.isFunctionLike() || macro.arguments().isEmpty())
|
||||||
@@ -130,8 +128,7 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons
|
|||||||
return astVisitor.testBaseName();
|
return astVisitor.testBaseName();
|
||||||
|
|
||||||
// check for precompiled headers
|
// check for precompiled headers
|
||||||
static QStringList expectedHeaderPrefixes
|
static QStringList expectedHeaderPrefixes = HostOsInfo::isMacHost()
|
||||||
= Utils::HostOsInfo::isMacHost()
|
|
||||||
? QStringList({"QtQuickTest.framework/Headers", "QtQuickTest"})
|
? QStringList({"QtQuickTest.framework/Headers", "QtQuickTest"})
|
||||||
: QStringList({"QtQuickTest"});
|
: QStringList({"QtQuickTest"});
|
||||||
bool pchIncludes = false;
|
bool pchIncludes = false;
|
||||||
@@ -152,9 +149,9 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Utils::FilePath &srcDir)
|
QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const FilePath &srcDir)
|
||||||
{
|
{
|
||||||
Utils::FilePaths dirs({srcDir});
|
FilePaths dirs({srcDir});
|
||||||
QStringList dirsStr({srcDir.toString()});
|
QStringList dirsStr({srcDir.toString()});
|
||||||
ModelManagerInterface *qmlJsMM = QmlJSTools::Internal::ModelManager::instance();
|
ModelManagerInterface *qmlJsMM = QmlJSTools::Internal::ModelManager::instance();
|
||||||
// make sure even files not listed in pro file are available inside the snapshot
|
// make sure even files not listed in pro file are available inside the snapshot
|
||||||
@@ -171,7 +168,7 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Ut
|
|||||||
QDirIterator::Subdirectories);
|
QDirIterator::Subdirectories);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
auto subDir = Utils::FilePath::fromFileInfo(it.fileInfo()).canonicalPath();
|
auto subDir = FilePath::fromFileInfo(it.fileInfo()).canonicalPath();
|
||||||
dirs.append(subDir);
|
dirs.append(subDir);
|
||||||
dirsStr.append(subDir.toString());
|
dirsStr.append(subDir.toString());
|
||||||
}
|
}
|
||||||
@@ -182,10 +179,10 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Ut
|
|||||||
|
|
||||||
QList<Document::Ptr> foundDocs;
|
QList<Document::Ptr> foundDocs;
|
||||||
|
|
||||||
for (const Utils::FilePath &path : std::as_const(dirs)) {
|
for (const FilePath &path : std::as_const(dirs)) {
|
||||||
const QList<Document::Ptr> docs = snapshot.documentsInDirectory(path);
|
const QList<Document::Ptr> docs = snapshot.documentsInDirectory(path);
|
||||||
for (const Document::Ptr &doc : docs) {
|
for (const Document::Ptr &doc : docs) {
|
||||||
Utils::FilePath fi = doc->fileName();
|
const FilePath fi = doc->fileName();
|
||||||
//const QFileInfo fi(doc->fileName());
|
//const QFileInfo fi(doc->fileName());
|
||||||
// using working copy above might provide no more existing files
|
// using working copy above might provide no more existing files
|
||||||
if (!fi.exists())
|
if (!fi.exists())
|
||||||
@@ -202,7 +199,7 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Ut
|
|||||||
static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr> &futureInterface,
|
static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||||
const Document::Ptr &qmlJSDoc,
|
const Document::Ptr &qmlJSDoc,
|
||||||
ITestFramework *framework,
|
ITestFramework *framework,
|
||||||
const Utils::FilePath &proFile = {},
|
const FilePath &proFile = {},
|
||||||
bool checkForDerivedTest = false)
|
bool checkForDerivedTest = false)
|
||||||
{
|
{
|
||||||
if (qmlJSDoc.isNull())
|
if (qmlJSDoc.isNull())
|
||||||
@@ -260,10 +257,9 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> &fu
|
|||||||
if (ppList.isEmpty()) // happens if shutting down while parsing
|
if (ppList.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
const FilePath cppFileName = document->filePath();
|
const FilePath cppFileName = document->filePath();
|
||||||
const FilePath proFile = Utils::FilePath::fromString(ppList.at(0)->projectFile);
|
const FilePath proFile = FilePath::fromString(ppList.at(0)->projectFile);
|
||||||
m_mainCppFiles.insert(cppFileName, proFile);
|
m_mainCppFiles.insert(cppFileName, proFile);
|
||||||
const Utils::FilePath srcDir = Utils::FilePath::fromString(
|
const FilePath srcDir = FilePath::fromString(quickTestSrcDir(modelManager, cppFileName));
|
||||||
quickTestSrcDir(modelManager, cppFileName));
|
|
||||||
if (srcDir.isEmpty())
|
if (srcDir.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -308,7 +304,7 @@ void QuickTestParser::handleDirectoryChanged(const QString &directory)
|
|||||||
if (timestampChanged) {
|
if (timestampChanged) {
|
||||||
m_watchedFiles[directory] = filesAndDates;
|
m_watchedFiles[directory] = filesAndDates;
|
||||||
PathsAndLanguages paths;
|
PathsAndLanguages paths;
|
||||||
paths.maybeInsert(Utils::FilePath::fromString(directory), Dialect::Qml);
|
paths.maybeInsert(FilePath::fromString(directory), Dialect::Qml);
|
||||||
QFutureInterface<void> future;
|
QFutureInterface<void> future;
|
||||||
ModelManagerInterface *qmlJsMM = ModelManagerInterface::instance();
|
ModelManagerInterface *qmlJsMM = ModelManagerInterface::instance();
|
||||||
ModelManagerInterface::importScan(future, ModelManagerInterface::workingCopy(), paths,
|
ModelManagerInterface::importScan(future, ModelManagerInterface::workingCopy(), paths,
|
||||||
@@ -342,14 +338,14 @@ QuickTestParser::QuickTestParser(ITestFramework *framework)
|
|||||||
this, &QuickTestParser::handleDirectoryChanged);
|
this, &QuickTestParser::handleDirectoryChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
void QuickTestParser::init(const FilePaths &filesToParse, bool fullParse)
|
||||||
{
|
{
|
||||||
m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
|
m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
|
||||||
if (!fullParse) {
|
if (!fullParse) {
|
||||||
// in a full parse we get the correct entry points by the respective main
|
// in a full parse we get the correct entry points by the respective main
|
||||||
m_proFilesForQmlFiles = QuickTestUtils::proFilesForQmlFiles(framework(), filesToParse);
|
m_proFilesForQmlFiles = QuickTestUtils::proFilesForQmlFiles(framework(), filesToParse);
|
||||||
// get rid of cached main cpp files that are going to get processed anyhow
|
// get rid of cached main cpp files that are going to get processed anyhow
|
||||||
for (const Utils::FilePath &file : filesToParse) {
|
for (const FilePath &file : filesToParse) {
|
||||||
if (m_mainCppFiles.contains(file)) {
|
if (m_mainCppFiles.contains(file)) {
|
||||||
m_mainCppFiles.remove(file);
|
m_mainCppFiles.remove(file);
|
||||||
if (m_mainCppFiles.isEmpty())
|
if (m_mainCppFiles.isEmpty())
|
||||||
@@ -375,10 +371,10 @@ void QuickTestParser::release()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||||
const Utils::FilePath &fileName)
|
const FilePath &fileName)
|
||||||
{
|
{
|
||||||
if (fileName.endsWith(".qml")) {
|
if (fileName.endsWith(".qml")) {
|
||||||
const Utils::FilePath &proFile = m_proFilesForQmlFiles.value(fileName);
|
const FilePath &proFile = m_proFilesForQmlFiles.value(fileName);
|
||||||
if (proFile.isEmpty())
|
if (proFile.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName);
|
Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName);
|
||||||
@@ -396,9 +392,9 @@ bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futu
|
|||||||
return handleQtQuickTest(futureInterface, cppdoc, framework());
|
return handleQtQuickTest(futureInterface, cppdoc, framework());
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FilePath QuickTestParser::projectFileForMainCppFile(const Utils::FilePath &fileName) const
|
FilePath QuickTestParser::projectFileForMainCppFile(const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : Utils::FilePath();
|
return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : FilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -12,10 +12,12 @@
|
|||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static QSet<QString> internalTargets(const Utils::FilePath &proFile);
|
static QSet<QString> internalTargets(const FilePath &proFile);
|
||||||
|
|
||||||
TestTreeItem *QuickTestTreeItem::copyWithoutChildren()
|
TestTreeItem *QuickTestTreeItem::copyWithoutChildren()
|
||||||
{
|
{
|
||||||
@@ -149,8 +151,8 @@ static QList<ITestConfiguration *> testConfigurationsFor(
|
|||||||
if (!project || rootNode->type() != TestTreeItem::Root)
|
if (!project || rootNode->type() != TestTreeItem::Root)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
QHash<Utils::FilePath, QuickTestConfiguration *> configurationForProFiles;
|
QHash<FilePath, QuickTestConfiguration *> configurationForProFiles;
|
||||||
rootNode->forSelectedChildren([&predicate, &configurationForProFiles](Utils::TreeItem *it) {
|
rootNode->forSelectedChildren([&predicate, &configurationForProFiles](TreeItem *it) {
|
||||||
auto treeItem = static_cast<TestTreeItem *>(it);
|
auto treeItem = static_cast<TestTreeItem *>(it);
|
||||||
if (treeItem->type() == TestTreeItem::Root || treeItem->type() == TestTreeItem::GroupNode)
|
if (treeItem->type() == TestTreeItem::Root || treeItem->type() == TestTreeItem::GroupNode)
|
||||||
return true;
|
return true;
|
||||||
@@ -208,12 +210,12 @@ QList<ITestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const
|
|||||||
if (!project || type() != Root)
|
if (!project || type() != Root)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QHash<Utils::FilePath, Tests> testsForProfile;
|
QHash<FilePath, Tests> testsForProfile;
|
||||||
forFirstLevelChildItems([&testsForProfile](TestTreeItem *child) {
|
forFirstLevelChildItems([&testsForProfile](TestTreeItem *child) {
|
||||||
// unnamed Quick Tests must be handled separately
|
// unnamed Quick Tests must be handled separately
|
||||||
if (child->name().isEmpty()) {
|
if (child->name().isEmpty()) {
|
||||||
child->forFirstLevelChildItems([&testsForProfile](TestTreeItem *grandChild) {
|
child->forFirstLevelChildItems([&testsForProfile](TestTreeItem *grandChild) {
|
||||||
const Utils::FilePath &proFile = grandChild->proFile();
|
const FilePath &proFile = grandChild->proFile();
|
||||||
++(testsForProfile[proFile].testCount);
|
++(testsForProfile[proFile].testCount);
|
||||||
testsForProfile[proFile].internalTargets = internalTargets(grandChild->proFile());
|
testsForProfile[proFile].internalTargets = internalTargets(grandChild->proFile());
|
||||||
});
|
});
|
||||||
@@ -255,7 +257,7 @@ QList<ITestConfiguration *> QuickTestTreeItem::getFailedTestConfigurations() con
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<ITestConfiguration *> QuickTestTreeItem::getTestConfigurationsForFile(
|
QList<ITestConfiguration *> QuickTestTreeItem::getTestConfigurationsForFile(
|
||||||
const Utils::FilePath &fileName) const
|
const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
return testConfigurationsFor(this, [&fileName](TestTreeItem *it) {
|
return testConfigurationsFor(this, [&fileName](TestTreeItem *it) {
|
||||||
return it->filePath() == fileName;
|
return it->filePath() == fileName;
|
||||||
@@ -271,7 +273,7 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
|
|||||||
if (result->name.isEmpty())
|
if (result->name.isEmpty())
|
||||||
return unnamedQuickTests();
|
return unnamedQuickTests();
|
||||||
if (result->framework->grouping()) {
|
if (result->framework->grouping()) {
|
||||||
const Utils::FilePath path = result->fileName.absolutePath();
|
const FilePath path = result->fileName.absolutePath();
|
||||||
TestTreeItem *group = findFirstLevelChildItem([path](TestTreeItem *group) {
|
TestTreeItem *group = findFirstLevelChildItem([path](TestTreeItem *group) {
|
||||||
return group->filePath() == path;
|
return group->filePath() == path;
|
||||||
});
|
});
|
||||||
@@ -354,7 +356,7 @@ bool QuickTestTreeItem::removeOnSweepIfEmpty() const
|
|||||||
|
|
||||||
TestTreeItem *QuickTestTreeItem::createParentGroupNode() const
|
TestTreeItem *QuickTestTreeItem::createParentGroupNode() const
|
||||||
{
|
{
|
||||||
const Utils::FilePath &absPath = filePath().absolutePath();
|
const FilePath &absPath = filePath().absolutePath();
|
||||||
return new QuickTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
return new QuickTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +365,7 @@ bool QuickTestTreeItem::isGroupable() const
|
|||||||
return type() == TestCase && !name().isEmpty() && !filePath().isEmpty();
|
return type() == TestCase && !name().isEmpty() && !filePath().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> internalTargets(const Utils::FilePath &proFile)
|
QSet<QString> internalTargets(const FilePath &proFile)
|
||||||
{
|
{
|
||||||
QSet<QString> result;
|
QSet<QString> result;
|
||||||
const auto cppMM = CppEditor::CppModelManager::instance();
|
const auto cppMM = CppEditor::CppModelManager::instance();
|
||||||
@@ -379,11 +381,11 @@ QSet<QString> internalTargets(const Utils::FilePath &proFile)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickTestTreeItem::markForRemovalRecursively(const Utils::FilePath &filePath)
|
void QuickTestTreeItem::markForRemovalRecursively(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
TestTreeItem::markForRemovalRecursively(filePath);
|
TestTreeItem::markForRemovalRecursively(filePath);
|
||||||
auto parser = static_cast<QuickTestParser *>(framework()->testParser());
|
auto parser = static_cast<QuickTestParser *>(framework()->testParser());
|
||||||
const Utils::FilePath proFile = parser->projectFileForMainCppFile(filePath);
|
const FilePath proFile = parser->projectFileForMainCppFile(filePath);
|
||||||
if (!proFile.isEmpty()) {
|
if (!proFile.isEmpty()) {
|
||||||
TestTreeItem *root = framework()->rootNode();
|
TestTreeItem *root = framework()->rootNode();
|
||||||
root->forAllChildItems([proFile](TestTreeItem *it) {
|
root->forAllChildItems([proFile](TestTreeItem *it) {
|
||||||
@@ -393,7 +395,7 @@ void QuickTestTreeItem::markForRemovalRecursively(const Utils::FilePath &filePat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const Utils::FilePath &filePath,
|
TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const FilePath &filePath,
|
||||||
const QString &name,
|
const QString &name,
|
||||||
TestTreeItem::Type tType)
|
TestTreeItem::Type tType)
|
||||||
|
|
||||||
@@ -404,7 +406,7 @@ TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const Utils::FilePat
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestTreeItem *QuickTestTreeItem::findChildByNameFileAndLine(const QString &name,
|
TestTreeItem *QuickTestTreeItem::findChildByNameFileAndLine(const QString &name,
|
||||||
const Utils::FilePath &filePath,
|
const FilePath &filePath,
|
||||||
int line)
|
int line)
|
||||||
{
|
{
|
||||||
return findFirstLevelChildItem([name, filePath, line](const TestTreeItem *other) {
|
return findFirstLevelChildItem([name, filePath, line](const TestTreeItem *other) {
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -146,12 +148,12 @@ void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers)
|
|||||||
[](const ITestParser *lhs, const ITestParser *rhs) {
|
[](const ITestParser *lhs, const ITestParser *rhs) {
|
||||||
return lhs->framework()->priority() < rhs->framework()->priority();
|
return lhs->framework()->priority() < rhs->framework()->priority();
|
||||||
});
|
});
|
||||||
scanForTests(Utils::FilePaths(), sortedParsers);
|
scanForTests({}, sortedParsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****** threaded parsing stuff *******/
|
/****** threaded parsing stuff *******/
|
||||||
|
|
||||||
void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile)
|
void TestCodeParser::onDocumentUpdated(const FilePath &fileName, bool isQmlFile)
|
||||||
{
|
{
|
||||||
if (isProjectParsing() || m_codeModelParsing || m_postponedUpdateType == UpdateType::FullUpdate)
|
if (isProjectParsing() || m_codeModelParsing || m_postponedUpdateType == UpdateType::FullUpdate)
|
||||||
return;
|
return;
|
||||||
@@ -163,7 +165,7 @@ void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQ
|
|||||||
if (!isQmlFile && !project->isKnownFile(fileName))
|
if (!isQmlFile && !project->isKnownFile(fileName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scanForTests(Utils::FilePaths{fileName});
|
scanForTests({fileName});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document)
|
void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document)
|
||||||
@@ -174,7 +176,7 @@ void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &docume
|
|||||||
void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
|
void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
|
||||||
{
|
{
|
||||||
static const QStringList ignoredSuffixes{ "qbs", "ui.qml" };
|
static const QStringList ignoredSuffixes{ "qbs", "ui.qml" };
|
||||||
const Utils::FilePath fileName = document->fileName();
|
const FilePath fileName = document->fileName();
|
||||||
if (!ignoredSuffixes.contains(fileName.suffix()))
|
if (!ignoredSuffixes.contains(fileName.suffix()))
|
||||||
onDocumentUpdated(fileName, true);
|
onDocumentUpdated(fileName, true);
|
||||||
}
|
}
|
||||||
@@ -211,7 +213,7 @@ void TestCodeParser::aboutToShutdown()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestCodeParser::postponed(const Utils::FilePaths &fileList)
|
bool TestCodeParser::postponed(const FilePaths &fileList)
|
||||||
{
|
{
|
||||||
switch (m_parserState) {
|
switch (m_parserState) {
|
||||||
case Idle:
|
case Idle:
|
||||||
@@ -253,7 +255,7 @@ bool TestCodeParser::postponed(const Utils::FilePaths &fileList)
|
|||||||
if (m_postponedUpdateType == UpdateType::FullUpdate)
|
if (m_postponedUpdateType == UpdateType::FullUpdate)
|
||||||
return true;
|
return true;
|
||||||
// partial parse triggered, postpone or add current files to already postponed partial
|
// partial parse triggered, postpone or add current files to already postponed partial
|
||||||
for (const Utils::FilePath &file : fileList)
|
for (const FilePath &file : fileList)
|
||||||
m_postponedFiles.insert(file);
|
m_postponedFiles.insert(file);
|
||||||
m_postponedUpdateType = UpdateType::PartialUpdate;
|
m_postponedUpdateType = UpdateType::PartialUpdate;
|
||||||
}
|
}
|
||||||
@@ -266,7 +268,7 @@ bool TestCodeParser::postponed(const Utils::FilePaths &fileList)
|
|||||||
|
|
||||||
static void parseFileForTests(const QList<ITestParser *> &parsers,
|
static void parseFileForTests(const QList<ITestParser *> &parsers,
|
||||||
QFutureInterface<TestParseResultPtr> &futureInterface,
|
QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||||
const Utils::FilePath &fileName)
|
const FilePath &fileName)
|
||||||
{
|
{
|
||||||
for (ITestParser *parser : parsers) {
|
for (ITestParser *parser : parsers) {
|
||||||
if (futureInterface.isCanceled())
|
if (futureInterface.isCanceled())
|
||||||
@@ -276,8 +278,7 @@ static void parseFileForTests(const QList<ITestParser *> &parsers,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
void TestCodeParser::scanForTests(const FilePaths &fileList, const QList<ITestParser *> &parsers)
|
||||||
const QList<ITestParser *> &parsers)
|
|
||||||
{
|
{
|
||||||
if (m_parserState == Shutdown || m_testCodeParsers.isEmpty())
|
if (m_parserState == Shutdown || m_testCodeParsers.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -292,7 +293,7 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
|||||||
Project *project = SessionManager::startupProject();
|
Project *project = SessionManager::startupProject();
|
||||||
if (!project)
|
if (!project)
|
||||||
return;
|
return;
|
||||||
Utils::FilePaths list;
|
FilePaths list;
|
||||||
if (isFullParse) {
|
if (isFullParse) {
|
||||||
list = project->files(Project::SourceFiles);
|
list = project->files(Project::SourceFiles);
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
@@ -318,7 +319,7 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
|||||||
TestTreeModel::instance()->updateCheckStateCache();
|
TestTreeModel::instance()->updateCheckStateCache();
|
||||||
if (isFullParse) {
|
if (isFullParse) {
|
||||||
// remove qml files as they will be found automatically by the referencing cpp file
|
// remove qml files as they will be found automatically by the referencing cpp file
|
||||||
list = Utils::filtered(list, [](const Utils::FilePath &fn) {
|
list = Utils::filtered(list, [](const FilePath &fn) {
|
||||||
return !fn.endsWith(".qml");
|
return !fn.endsWith(".qml");
|
||||||
});
|
});
|
||||||
if (!parsers.isEmpty()) {
|
if (!parsers.isEmpty()) {
|
||||||
@@ -330,11 +331,11 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
|||||||
}
|
}
|
||||||
} else if (!parsers.isEmpty()) {
|
} else if (!parsers.isEmpty()) {
|
||||||
for (ITestParser *parser: parsers) {
|
for (ITestParser *parser: parsers) {
|
||||||
for (const Utils::FilePath &filePath : std::as_const(list))
|
for (const FilePath &filePath : std::as_const(list))
|
||||||
parser->framework()->rootNode()->markForRemovalRecursively(filePath);
|
parser->framework()->rootNode()->markForRemovalRecursively(filePath);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const Utils::FilePath &filePath : std::as_const(list))
|
for (const FilePath &filePath : std::as_const(list))
|
||||||
emit requestRemoval(filePath);
|
emit requestRemoval(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,8 +354,8 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
|||||||
}
|
}
|
||||||
// We are only interested in files that have been either parsed by the c++ parser,
|
// We are only interested in files that have been either parsed by the c++ parser,
|
||||||
// or have an extension that one of the parsers is specifically interested in.
|
// or have an extension that one of the parsers is specifically interested in.
|
||||||
const Utils::FilePaths filteredList
|
const FilePaths filteredList
|
||||||
= Utils::filtered(list, [&extensions, &cppSnapshot](const Utils::FilePath &fn) {
|
= Utils::filtered(list, [&extensions, &cppSnapshot](const FilePath &fn) {
|
||||||
const bool isSupportedExtension = Utils::anyOf(extensions, [&fn](const QString &ext) {
|
const bool isSupportedExtension = Utils::anyOf(extensions, [&fn](const QString &ext) {
|
||||||
return fn.suffix() == ext;
|
return fn.suffix() == ext;
|
||||||
});
|
});
|
||||||
@@ -366,12 +367,11 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
|||||||
qCDebug(LOG) << "Starting scan of" << filteredList.size() << "(" << list.size() << ")"
|
qCDebug(LOG) << "Starting scan of" << filteredList.size() << "(" << list.size() << ")"
|
||||||
<< "files with" << codeParsers.size() << "parsers";
|
<< "files with" << codeParsers.size() << "parsers";
|
||||||
|
|
||||||
QFuture<TestParseResultPtr> future = Utils::map(
|
QFuture<TestParseResultPtr> future = Utils::map(filteredList,
|
||||||
filteredList,
|
[codeParsers](QFutureInterface<TestParseResultPtr> &fi, const FilePath &file) {
|
||||||
[codeParsers](QFutureInterface<TestParseResultPtr> &fi, const Utils::FilePath &file) {
|
|
||||||
parseFileForTests(codeParsers, fi, file);
|
parseFileForTests(codeParsers, fi, file);
|
||||||
},
|
},
|
||||||
Utils::MapReduceOption::Unordered,
|
MapReduceOption::Unordered,
|
||||||
m_threadPool,
|
m_threadPool,
|
||||||
QThread::LowestPriority);
|
QThread::LowestPriority);
|
||||||
m_futureWatcher.setFuture(future);
|
m_futureWatcher.setFuture(future);
|
||||||
@@ -381,7 +381,7 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCodeParser::onTaskStarted(Utils::Id type)
|
void TestCodeParser::onTaskStarted(Id type)
|
||||||
{
|
{
|
||||||
if (type == CppEditor::Constants::TASK_INDEX) {
|
if (type == CppEditor::Constants::TASK_INDEX) {
|
||||||
m_codeModelParsing = true;
|
m_codeModelParsing = true;
|
||||||
@@ -395,7 +395,7 @@ void TestCodeParser::onTaskStarted(Utils::Id type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCodeParser::onAllTasksFinished(Utils::Id type)
|
void TestCodeParser::onAllTasksFinished(Id type)
|
||||||
{
|
{
|
||||||
// if we cancel parsing ensure that progress animation is canceled as well
|
// if we cancel parsing ensure that progress animation is canceled as well
|
||||||
if (type == Constants::TASK_PARSE && m_parsingHasFailed)
|
if (type == Constants::TASK_PARSE && m_parsingHasFailed)
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -48,10 +50,8 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
|
|||||||
m_view->setItemDelegate(new TestTreeItemDelegate(this));
|
m_view->setItemDelegate(new TestTreeItemDelegate(this));
|
||||||
|
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
pal.setColor(QPalette::Window,
|
pal.setColor(QPalette::Window, creatorTheme()->color(Theme::InfoBarBackground));
|
||||||
Utils::creatorTheme()->color(Utils::Theme::InfoBarBackground));
|
pal.setColor(QPalette::WindowText, creatorTheme()->color(Theme::InfoBarText));
|
||||||
pal.setColor(QPalette::WindowText,
|
|
||||||
Utils::creatorTheme()->color(Utils::Theme::InfoBarText));
|
|
||||||
m_missingFrameworksWidget = new QFrame;
|
m_missingFrameworksWidget = new QFrame;
|
||||||
m_missingFrameworksWidget->setPalette(pal);
|
m_missingFrameworksWidget->setPalette(pal);
|
||||||
m_missingFrameworksWidget->setAutoFillBackground(true);
|
m_missingFrameworksWidget->setAutoFillBackground(true);
|
||||||
@@ -70,7 +70,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
|
|||||||
|
|
||||||
connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated);
|
connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated);
|
||||||
|
|
||||||
m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Medium, this);
|
m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Medium, this);
|
||||||
m_progressIndicator->attachToWidget(m_view);
|
m_progressIndicator->attachToWidget(m_view);
|
||||||
m_progressIndicator->hide();
|
m_progressIndicator->hide();
|
||||||
|
|
||||||
@@ -94,8 +94,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
|
|||||||
});
|
});
|
||||||
connect(m_model, &TestTreeModel::testTreeModelChanged,
|
connect(m_model, &TestTreeModel::testTreeModelChanged,
|
||||||
this, &TestNavigationWidget::reapplyCachedExpandedState);
|
this, &TestNavigationWidget::reapplyCachedExpandedState);
|
||||||
connect(m_progressTimer, &QTimer::timeout,
|
connect(m_progressTimer, &QTimer::timeout, m_progressIndicator, &ProgressIndicator::show);
|
||||||
m_progressIndicator, &Utils::ProgressIndicator::show);
|
|
||||||
connect(m_view, &TestTreeView::expanded, this, &TestNavigationWidget::updateExpandedStateCache);
|
connect(m_view, &TestTreeView::expanded, this, &TestNavigationWidget::updateExpandedStateCache);
|
||||||
connect(m_view, &TestTreeView::collapsed, this, &TestNavigationWidget::updateExpandedStateCache);
|
connect(m_view, &TestTreeView::collapsed, this, &TestNavigationWidget::updateExpandedStateCache);
|
||||||
}
|
}
|
||||||
@@ -233,8 +232,8 @@ void TestNavigationWidget::updateExpandedStateCache()
|
|||||||
{
|
{
|
||||||
m_expandedStateCache.evolve(ITestBase::Framework);
|
m_expandedStateCache.evolve(ITestBase::Framework);
|
||||||
|
|
||||||
for (Utils::TreeItem *rootNode : *m_model->rootItem()) {
|
for (TreeItem *rootNode : *m_model->rootItem()) {
|
||||||
rootNode->forAllChildren([this](Utils::TreeItem *child) {
|
rootNode->forAllChildren([this](TreeItem *child) {
|
||||||
m_expandedStateCache.insert(static_cast<ITestTreeItem *>(child),
|
m_expandedStateCache.insert(static_cast<ITestTreeItem *>(child),
|
||||||
m_view->isExpanded(child->index()));
|
m_view->isExpanded(child->index()));
|
||||||
});
|
});
|
||||||
@@ -243,7 +242,7 @@ void TestNavigationWidget::updateExpandedStateCache()
|
|||||||
|
|
||||||
void TestNavigationWidget::onItemActivated(const QModelIndex &index)
|
void TestNavigationWidget::onItemActivated(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
const Utils::Link link = index.data(LinkRole).value<Utils::Link>();
|
const Link link = index.data(LinkRole).value<Link>();
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
Core::EditorManager::openEditorAt(link);
|
Core::EditorManager::openEditorAt(link);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,18 +16,18 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
|
|
||||||
Utils::FilePath TestOutputReader::constructSourceFilePath(const Utils::FilePath &path,
|
FilePath TestOutputReader::constructSourceFilePath(const FilePath &path, const QString &file)
|
||||||
const QString &file)
|
|
||||||
{
|
{
|
||||||
const Utils::FilePath filePath = path.resolvePath(file);
|
const FilePath filePath = path.resolvePath(file);
|
||||||
return filePath.isReadableFile() ? filePath : Utils::FilePath();
|
return filePath.isReadableFile() ? filePath : FilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||||
Utils::QtcProcess *testApplication,
|
QtcProcess *testApplication, const FilePath &buildDirectory)
|
||||||
const Utils::FilePath &buildDirectory)
|
|
||||||
: m_futureInterface(futureInterface)
|
: m_futureInterface(futureInterface)
|
||||||
, m_testApplication(testApplication)
|
, m_testApplication(testApplication)
|
||||||
, m_buildDir(buildDirectory)
|
, m_buildDir(buildDirectory)
|
||||||
@@ -149,10 +149,10 @@ void TestOutputReader::checkForSanitizerOutput(const QByteArray &line)
|
|||||||
m_sanitizerLines.append("Sanitizer Issue");
|
m_sanitizerLines.append("Sanitizer Issue");
|
||||||
m_sanitizerLines.append(lineStr);
|
m_sanitizerLines.append(lineStr);
|
||||||
if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) {
|
if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) {
|
||||||
const Utils::FilePath path = constructSourceFilePath(m_buildDir, match.captured(1));
|
const FilePath path = constructSourceFilePath(m_buildDir, match.captured(1));
|
||||||
// path may be empty if not existing - so, provide at least what we have
|
// path may be empty if not existing - so, provide at least what we have
|
||||||
m_sanitizerResult.setFileName(
|
m_sanitizerResult.setFileName(
|
||||||
path.exists() ? path : Utils::FilePath::fromString(match.captured(1)));
|
path.exists() ? path : FilePath::fromString(match.captured(1)));
|
||||||
m_sanitizerResult.setLine(match.captured(2).toInt());
|
m_sanitizerResult.setLine(match.captured(2).toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ void TestProjectSettings::setUseGlobalSettings(bool useGlobal)
|
|||||||
m_useGlobalSettings = useGlobal;
|
m_useGlobalSettings = useGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestProjectSettings::activateFramework(const Utils::Id &id, bool activate)
|
void TestProjectSettings::activateFramework(const Id &id, bool activate)
|
||||||
{
|
{
|
||||||
ITestFramework *framework = TestFrameworkManager::frameworkForId(id);
|
ITestFramework *framework = TestFrameworkManager::frameworkForId(id);
|
||||||
m_activeTestFrameworks[framework] = activate;
|
m_activeTestFrameworks[framework] = activate;
|
||||||
@@ -51,7 +53,7 @@ void TestProjectSettings::activateFramework(const Utils::Id &id, bool activate)
|
|||||||
framework->resetRootNode();
|
framework->resetRootNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestProjectSettings::activateTestTool(const Utils::Id &id, bool activate)
|
void TestProjectSettings::activateTestTool(const Id &id, bool activate)
|
||||||
{
|
{
|
||||||
ITestTool *testTool = TestFrameworkManager::testToolForId(id);
|
ITestTool *testTool = TestFrameworkManager::testToolForId(id);
|
||||||
m_activeTestTools[testTool] = activate;
|
m_activeTestTools[testTool] = activate;
|
||||||
@@ -74,12 +76,12 @@ void TestProjectSettings::load()
|
|||||||
if (activeFrameworks.isValid()) {
|
if (activeFrameworks.isValid()) {
|
||||||
const QMap<QString, QVariant> frameworksMap = activeFrameworks.toMap();
|
const QMap<QString, QVariant> frameworksMap = activeFrameworks.toMap();
|
||||||
for (ITestFramework *framework : registeredFrameworks) {
|
for (ITestFramework *framework : registeredFrameworks) {
|
||||||
const Utils::Id id = framework->id();
|
const Id id = framework->id();
|
||||||
bool active = frameworksMap.value(id.toString(), framework->active()).toBool();
|
bool active = frameworksMap.value(id.toString(), framework->active()).toBool();
|
||||||
m_activeTestFrameworks.insert(framework, active);
|
m_activeTestFrameworks.insert(framework, active);
|
||||||
}
|
}
|
||||||
for (ITestTool *testTool : registeredTestTools) {
|
for (ITestTool *testTool : registeredTestTools) {
|
||||||
const Utils::Id id = testTool->id();
|
const Id id = testTool->id();
|
||||||
bool active = frameworksMap.value(id.toString(), testTool->active()).toBool();
|
bool active = frameworksMap.value(id.toString(), testTool->active()).toBool();
|
||||||
m_activeTestTools.insert(testTool, active);
|
m_activeTestTools.insert(testTool, active);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
|
|
||||||
TestResult::TestResult(const QString &id, const QString &name, const ResultHooks &hooks)
|
TestResult::TestResult(const QString &id, const QString &name, const ResultHooks &hooks)
|
||||||
@@ -131,33 +133,33 @@ QColor TestResult::colorForType(const ResultType type)
|
|||||||
if (type >= ResultType::INTERNAL_MESSAGES_BEGIN && type <= ResultType::INTERNAL_MESSAGES_END)
|
if (type >= ResultType::INTERNAL_MESSAGES_BEGIN && type <= ResultType::INTERNAL_MESSAGES_END)
|
||||||
return QColor("transparent");
|
return QColor("transparent");
|
||||||
|
|
||||||
Utils::Theme *creatorTheme = Utils::creatorTheme();
|
const Theme *theme = creatorTheme();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ResultType::Pass:
|
case ResultType::Pass:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestPassTextColor);
|
return theme->color(Theme::OutputPanes_TestPassTextColor);
|
||||||
case ResultType::Fail:
|
case ResultType::Fail:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestFailTextColor);
|
return theme->color(Theme::OutputPanes_TestFailTextColor);
|
||||||
case ResultType::ExpectedFail:
|
case ResultType::ExpectedFail:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestXFailTextColor);
|
return theme->color(Theme::OutputPanes_TestXFailTextColor);
|
||||||
case ResultType::UnexpectedPass:
|
case ResultType::UnexpectedPass:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestXPassTextColor);
|
return theme->color(Theme::OutputPanes_TestXPassTextColor);
|
||||||
case ResultType::Skip:
|
case ResultType::Skip:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestSkipTextColor);
|
return theme->color(Theme::OutputPanes_TestSkipTextColor);
|
||||||
case ResultType::MessageDebug:
|
case ResultType::MessageDebug:
|
||||||
case ResultType::MessageInfo:
|
case ResultType::MessageInfo:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestDebugTextColor);
|
return theme->color(Theme::OutputPanes_TestDebugTextColor);
|
||||||
case ResultType::MessageWarn:
|
case ResultType::MessageWarn:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestWarnTextColor);
|
return theme->color(Theme::OutputPanes_TestWarnTextColor);
|
||||||
case ResultType::MessageFatal:
|
case ResultType::MessageFatal:
|
||||||
case ResultType::MessageSystem:
|
case ResultType::MessageSystem:
|
||||||
case ResultType::MessageError:
|
case ResultType::MessageError:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_TestFatalTextColor);
|
return theme->color(Theme::OutputPanes_TestFatalTextColor);
|
||||||
case ResultType::BlacklistedPass:
|
case ResultType::BlacklistedPass:
|
||||||
case ResultType::BlacklistedFail:
|
case ResultType::BlacklistedFail:
|
||||||
case ResultType::BlacklistedXPass:
|
case ResultType::BlacklistedXPass:
|
||||||
case ResultType::BlacklistedXFail:
|
case ResultType::BlacklistedXFail:
|
||||||
default:
|
default:
|
||||||
return creatorTheme->color(Utils::Theme::OutputPanes_StdOutTextColor);
|
return theme->color(Theme::OutputPanes_StdOutTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -83,7 +85,7 @@ QVariant TestResultItem::data(int column, int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return m_testResult.isValid() ? m_testResult.outputString(true) : QVariant();
|
return m_testResult.isValid() ? m_testResult.outputString(true) : QVariant();
|
||||||
default:
|
default:
|
||||||
return Utils::TreeItem::data(column, role);
|
return TreeItem::data(column, role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +200,7 @@ QString TestResultItem::resultString() const
|
|||||||
/********************************* TestResultModel *****************************************/
|
/********************************* TestResultModel *****************************************/
|
||||||
|
|
||||||
TestResultModel::TestResultModel(QObject *parent)
|
TestResultModel::TestResultModel(QObject *parent)
|
||||||
: Utils::TreeModel<TestResultItem>(new TestResultItem({}), parent)
|
: TreeModel<TestResultItem>(new TestResultItem({}), parent)
|
||||||
{
|
{
|
||||||
connect(TestRunner::instance(), &TestRunner::reportSummary,
|
connect(TestRunner::instance(), &TestRunner::reportSummary,
|
||||||
this, [this](const QString &id, const QHash<ResultType, int> &summary){
|
this, [this](const QString &id, const QHash<ResultType, int> &summary){
|
||||||
@@ -281,7 +283,7 @@ void TestResultModel::addTestResult(const TestResult &testResult, bool autoExpan
|
|||||||
if (autoExpand) {
|
if (autoExpand) {
|
||||||
parentItem->expand();
|
parentItem->expand();
|
||||||
newItem->expand();
|
newItem->expand();
|
||||||
newItem->forAllChildren([](Utils::TreeItem *it) { it->expand(); });
|
newItem->forAllChildren([](TreeItem *it) { it->expand(); });
|
||||||
}
|
}
|
||||||
updateParent(newItem);
|
updateParent(newItem);
|
||||||
} else {
|
} else {
|
||||||
@@ -399,7 +401,7 @@ TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
|
|||||||
return root;
|
return root;
|
||||||
|
|
||||||
bool needsIntermediate = false;
|
bool needsIntermediate = false;
|
||||||
auto predicate = [result, &needsIntermediate](Utils::TreeItem *it) {
|
auto predicate = [result, &needsIntermediate](TreeItem *it) {
|
||||||
TestResultItem *currentItem = static_cast<TestResultItem *>(it);
|
TestResultItem *currentItem = static_cast<TestResultItem *>(it);
|
||||||
return currentItem->testResult().isDirectParentOf(result, &needsIntermediate);
|
return currentItem->testResult().isDirectParentOf(result, &needsIntermediate);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace Autotest {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
ResultsTreeView::ResultsTreeView(QWidget *parent)
|
ResultsTreeView::ResultsTreeView(QWidget *parent)
|
||||||
: Utils::TreeView(parent)
|
: TreeView(parent)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
setFrameStyle(NoFrame);
|
setFrameStyle(NoFrame);
|
||||||
@@ -84,10 +84,8 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
|||||||
visualOutputWidget->setLayout(outputLayout);
|
visualOutputWidget->setLayout(outputLayout);
|
||||||
|
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
pal.setColor(QPalette::Window,
|
pal.setColor(QPalette::Window, creatorTheme()->color(Theme::InfoBarBackground));
|
||||||
Utils::creatorTheme()->color(Utils::Theme::InfoBarBackground));
|
pal.setColor(QPalette::WindowText, creatorTheme()->color(Theme::InfoBarText));
|
||||||
pal.setColor(QPalette::WindowText,
|
|
||||||
Utils::creatorTheme()->color(Utils::Theme::InfoBarText));
|
|
||||||
m_summaryWidget = new QFrame;
|
m_summaryWidget = new QFrame;
|
||||||
m_summaryWidget->setPalette(pal);
|
m_summaryWidget->setPalette(pal);
|
||||||
m_summaryWidget->setAutoFillBackground(true);
|
m_summaryWidget->setAutoFillBackground(true);
|
||||||
@@ -130,10 +128,10 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
|||||||
|
|
||||||
createToolButtons();
|
createToolButtons();
|
||||||
|
|
||||||
connect(m_treeView, &Utils::TreeView::activated, this, &TestResultsPane::onItemActivated);
|
connect(m_treeView, &TreeView::activated, this, &TestResultsPane::onItemActivated);
|
||||||
connect(m_treeView->selectionModel(), &QItemSelectionModel::currentChanged,
|
connect(m_treeView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||||
trd, &TestResultDelegate::currentChanged);
|
trd, &TestResultDelegate::currentChanged);
|
||||||
connect(m_treeView, &Utils::TreeView::customContextMenuRequested,
|
connect(m_treeView, &TreeView::customContextMenuRequested,
|
||||||
this, &TestResultsPane::onCustomContextMenuRequested);
|
this, &TestResultsPane::onCustomContextMenuRequested);
|
||||||
connect(m_treeView, &ResultsTreeView::copyShortcutTriggered, this, [this] {
|
connect(m_treeView, &ResultsTreeView::copyShortcutTriggered, this, [this] {
|
||||||
onCopyItemTriggered(getTestResult(m_treeView->currentIndex()));
|
onCopyItemTriggered(getTestResult(m_treeView->currentIndex()));
|
||||||
@@ -167,25 +165,21 @@ void TestResultsPane::createToolButtons()
|
|||||||
});
|
});
|
||||||
|
|
||||||
m_runAll = new QToolButton(m_treeView);
|
m_runAll = new QToolButton(m_treeView);
|
||||||
m_runAll->setDefaultAction(
|
m_runAll->setDefaultAction(ProxyAction::proxyActionWithIcon(
|
||||||
Utils::ProxyAction::proxyActionWithIcon(
|
|
||||||
ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action(),
|
ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action(),
|
||||||
Utils::Icons::RUN_SMALL_TOOLBAR.icon()));
|
Utils::Icons::RUN_SMALL_TOOLBAR.icon()));
|
||||||
|
|
||||||
m_runSelected = new QToolButton(m_treeView);
|
m_runSelected = new QToolButton(m_treeView);
|
||||||
m_runSelected->setDefaultAction(
|
m_runSelected->setDefaultAction(ProxyAction::proxyActionWithIcon(
|
||||||
Utils::ProxyAction::proxyActionWithIcon(
|
|
||||||
ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action(),
|
ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action(),
|
||||||
Utils::Icons::RUN_SELECTED_TOOLBAR.icon()));
|
Utils::Icons::RUN_SELECTED_TOOLBAR.icon()));
|
||||||
|
|
||||||
m_runFailed = new QToolButton(m_treeView);
|
m_runFailed = new QToolButton(m_treeView);
|
||||||
m_runFailed->setDefaultAction(
|
m_runFailed->setDefaultAction(ProxyAction::proxyActionWithIcon(
|
||||||
Utils::ProxyAction::proxyActionWithIcon(
|
|
||||||
ActionManager::command(Constants::ACTION_RUN_FAILED_ID)->action(),
|
ActionManager::command(Constants::ACTION_RUN_FAILED_ID)->action(),
|
||||||
Icons::RUN_FAILED_TOOLBAR.icon()));
|
Icons::RUN_FAILED_TOOLBAR.icon()));
|
||||||
m_runFile = new QToolButton(m_treeView);
|
m_runFile = new QToolButton(m_treeView);
|
||||||
m_runFile->setDefaultAction(
|
m_runFile->setDefaultAction(ProxyAction::proxyActionWithIcon(
|
||||||
Utils::ProxyAction::proxyActionWithIcon(
|
|
||||||
ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action(),
|
ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action(),
|
||||||
Utils::Icons::RUN_FILE_TOOLBAR.icon()));
|
Utils::Icons::RUN_FILE_TOOLBAR.icon()));
|
||||||
|
|
||||||
@@ -248,22 +242,22 @@ static void checkAndFineTuneColors(QTextCharFormat *format)
|
|||||||
const QColor bgColor = format->background().color();
|
const QColor bgColor = format->background().color();
|
||||||
QColor fgColor = format->foreground().color();
|
QColor fgColor = format->foreground().color();
|
||||||
|
|
||||||
if (Utils::StyleHelper::isReadableOn(bgColor, fgColor))
|
if (StyleHelper::isReadableOn(bgColor, fgColor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int h, s, v;
|
int h, s, v;
|
||||||
fgColor.getHsv(&h, &s, &v);
|
fgColor.getHsv(&h, &s, &v);
|
||||||
// adjust the color value to ensure better readability
|
// adjust the color value to ensure better readability
|
||||||
if (Utils::StyleHelper::luminance(bgColor) < .5)
|
if (StyleHelper::luminance(bgColor) < .5)
|
||||||
v = v + 64;
|
v = v + 64;
|
||||||
else
|
else
|
||||||
v = v - 64;
|
v = v - 64;
|
||||||
|
|
||||||
fgColor.setHsv(h, s, v);
|
fgColor.setHsv(h, s, v);
|
||||||
if (!Utils::StyleHelper::isReadableOn(bgColor, fgColor)) {
|
if (!StyleHelper::isReadableOn(bgColor, fgColor)) {
|
||||||
s = (s + 128) % 255; // adjust the saturation to ensure better readability
|
s = (s + 128) % 255; // adjust the saturation to ensure better readability
|
||||||
fgColor.setHsv(h, s, v);
|
fgColor.setHsv(h, s, v);
|
||||||
if (!Utils::StyleHelper::isReadableOn(bgColor, fgColor))
|
if (!StyleHelper::isReadableOn(bgColor, fgColor))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,9 +272,9 @@ void TestResultsPane::addOutputLine(const QByteArray &outputLine, OutputChannel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Utils::FormattedText formattedText
|
const FormattedText formattedText
|
||||||
= Utils::FormattedText{QString::fromUtf8(outputLine), m_defaultFormat};
|
= FormattedText{QString::fromUtf8(outputLine), m_defaultFormat};
|
||||||
const QList<Utils::FormattedText> formatted = channel == OutputChannel::StdOut
|
const QList<FormattedText> formatted = channel == OutputChannel::StdOut
|
||||||
? m_stdOutHandler.parseText(formattedText)
|
? m_stdOutHandler.parseText(formattedText)
|
||||||
: m_stdErrHandler.parseText(formattedText);
|
: m_stdErrHandler.parseText(formattedText);
|
||||||
|
|
||||||
@@ -332,9 +326,9 @@ void TestResultsPane::clearContents()
|
|||||||
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||||
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
||||||
m_textOutput->clear();
|
m_textOutput->clear();
|
||||||
m_defaultFormat.setBackground(Utils::creatorTheme()->palette().color(
|
m_defaultFormat.setBackground(creatorTheme()->palette().color(
|
||||||
m_textOutput->backgroundRole()));
|
m_textOutput->backgroundRole()));
|
||||||
m_defaultFormat.setForeground(Utils::creatorTheme()->palette().color(
|
m_defaultFormat.setForeground(creatorTheme()->palette().color(
|
||||||
m_textOutput->foregroundRole()));
|
m_textOutput->foregroundRole()));
|
||||||
|
|
||||||
// in case they had been forgotten to reset
|
// in case they had been forgotten to reset
|
||||||
@@ -402,7 +396,7 @@ void TestResultsPane::goToNext()
|
|||||||
|
|
||||||
// if we have no current or could not find a next one, use the first item of the whole tree
|
// if we have no current or could not find a next one, use the first item of the whole tree
|
||||||
if (!nextCurrentIndex.isValid()) {
|
if (!nextCurrentIndex.isValid()) {
|
||||||
Utils::TreeItem *rootItem = m_model->itemForIndex(QModelIndex());
|
TreeItem *rootItem = m_model->itemForIndex(QModelIndex());
|
||||||
// if the tree does not contain any item - don't do anything
|
// if the tree does not contain any item - don't do anything
|
||||||
if (!rootItem || !rootItem->childCount())
|
if (!rootItem || !rootItem->childCount())
|
||||||
return;
|
return;
|
||||||
@@ -459,7 +453,7 @@ void TestResultsPane::onItemActivated(const QModelIndex &index)
|
|||||||
|
|
||||||
const TestResult testResult = m_filterModel->testResult(index);
|
const TestResult testResult = m_filterModel->testResult(index);
|
||||||
if (testResult.isValid() && !testResult.fileName().isEmpty())
|
if (testResult.isValid() && !testResult.fileName().isEmpty())
|
||||||
EditorManager::openEditorAt(Utils::Link{testResult.fileName(), testResult.line(), 0});
|
EditorManager::openEditorAt(Link{testResult.fileName(), testResult.line(), 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestResultsPane::onRunAllTriggered()
|
void TestResultsPane::onRunAllTriggered()
|
||||||
@@ -754,7 +748,7 @@ void TestResultsPane::createMarks(const QModelIndex &parent)
|
|||||||
|| (isLocationItem && interested.contains(parentType))) {
|
|| (isLocationItem && interested.contains(parentType))) {
|
||||||
TestEditorMark *mark = new TestEditorMark(index, result.fileName(), result.line());
|
TestEditorMark *mark = new TestEditorMark(index, result.fileName(), result.line());
|
||||||
mark->setIcon(index.data(Qt::DecorationRole).value<QIcon>());
|
mark->setIcon(index.data(Qt::DecorationRole).value<QIcon>());
|
||||||
mark->setColor(Utils::Theme::OutputPanes_TestFailTextColor);
|
mark->setColor(Theme::OutputPanes_TestFailTextColor);
|
||||||
mark->setPriority(TextEditor::TextMark::NormalPriority);
|
mark->setPriority(TextEditor::TextMark::NormalPriority);
|
||||||
mark->setToolTip(result.description());
|
mark->setToolTip(result.description());
|
||||||
m_marks << mark;
|
m_marks << mark;
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -41,8 +43,8 @@ public:
|
|||||||
TestSettings settings() const;
|
TestSettings settings() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void populateFrameworksListWidget(const QHash<Utils::Id, bool> &frameworks,
|
void populateFrameworksListWidget(const QHash<Id, bool> &frameworks,
|
||||||
const QHash<Utils::Id, bool> &testTools);
|
const QHash<Id, bool> &testTools);
|
||||||
void testSettings(TestSettings &settings) const;
|
void testSettings(TestSettings &settings) const;
|
||||||
void testToolsSettings(TestSettings &settings) const;
|
void testToolsSettings(TestSettings &settings) const;
|
||||||
void onFrameworkItemChanged();
|
void onFrameworkItemChanged();
|
||||||
@@ -61,7 +63,7 @@ private:
|
|||||||
QComboBox *m_runAfterBuildCB;
|
QComboBox *m_runAfterBuildCB;
|
||||||
QSpinBox *m_timeoutSpin;
|
QSpinBox *m_timeoutSpin;
|
||||||
QTreeWidget *m_frameworkTreeWidget;
|
QTreeWidget *m_frameworkTreeWidget;
|
||||||
Utils::InfoLabel *m_frameworksWarn;
|
InfoLabel *m_frameworksWarn;
|
||||||
};
|
};
|
||||||
|
|
||||||
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
||||||
@@ -146,12 +148,12 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
|||||||
item->setText(1, Tr::tr("Group"));
|
item->setText(1, Tr::tr("Group"));
|
||||||
item->setToolTip(1, Tr::tr("Enables grouping of test cases."));
|
item->setToolTip(1, Tr::tr("Enables grouping of test cases."));
|
||||||
|
|
||||||
m_frameworksWarn = new Utils::InfoLabel;
|
m_frameworksWarn = new InfoLabel;
|
||||||
m_frameworksWarn->setVisible(false);
|
m_frameworksWarn->setVisible(false);
|
||||||
m_frameworksWarn->setElideMode(Qt::ElideNone);
|
m_frameworksWarn->setElideMode(Qt::ElideNone);
|
||||||
m_frameworksWarn->setType(Utils::InfoLabel::Warning);
|
m_frameworksWarn->setType(InfoLabel::Warning);
|
||||||
|
|
||||||
using namespace Utils::Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
PushButton resetChoicesButton {
|
PushButton resetChoicesButton {
|
||||||
text(Tr::tr("Reset Cached Choices")),
|
text(Tr::tr("Reset Cached Choices")),
|
||||||
@@ -249,13 +251,13 @@ enum TestBaseInfo
|
|||||||
BaseType
|
BaseType
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestSettingsWidget::populateFrameworksListWidget(const QHash<Utils::Id, bool> &frameworks,
|
void TestSettingsWidget::populateFrameworksListWidget(const QHash<Id, bool> &frameworks,
|
||||||
const QHash<Utils::Id, bool> &testTools)
|
const QHash<Id, bool> &testTools)
|
||||||
{
|
{
|
||||||
const TestFrameworks ®istered = TestFrameworkManager::registeredFrameworks();
|
const TestFrameworks ®istered = TestFrameworkManager::registeredFrameworks();
|
||||||
m_frameworkTreeWidget->clear();
|
m_frameworkTreeWidget->clear();
|
||||||
for (const ITestFramework *framework : registered) {
|
for (const ITestFramework *framework : registered) {
|
||||||
const Utils::Id id = framework->id();
|
const Id id = framework->id();
|
||||||
auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {framework->displayName()});
|
auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {framework->displayName()});
|
||||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
||||||
item->setCheckState(0, frameworks.value(id) ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(0, frameworks.value(id) ? Qt::Checked : Qt::Unchecked);
|
||||||
@@ -272,7 +274,7 @@ void TestSettingsWidget::populateFrameworksListWidget(const QHash<Utils::Id, boo
|
|||||||
// ...and now the test tools
|
// ...and now the test tools
|
||||||
const TestTools ®isteredTools = TestFrameworkManager::registeredTestTools();
|
const TestTools ®isteredTools = TestFrameworkManager::registeredTestTools();
|
||||||
for (const ITestTool *testTool : registeredTools) {
|
for (const ITestTool *testTool : registeredTools) {
|
||||||
const Utils::Id id = testTool->id();
|
const Id id = testTool->id();
|
||||||
auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {testTool->displayName()});
|
auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {testTool->displayName()});
|
||||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
||||||
item->setCheckState(0, testTools.value(id) ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(0, testTools.value(id) ? Qt::Checked : Qt::Unchecked);
|
||||||
@@ -289,7 +291,7 @@ void TestSettingsWidget::testSettings(TestSettings &settings) const
|
|||||||
QTC_ASSERT(itemCount <= model->rowCount(), return);
|
QTC_ASSERT(itemCount <= model->rowCount(), return);
|
||||||
for (int row = 0; row < itemCount; ++row) {
|
for (int row = 0; row < itemCount; ++row) {
|
||||||
QModelIndex idx = model->index(row, 0);
|
QModelIndex idx = model->index(row, 0);
|
||||||
const Utils::Id id = Utils::Id::fromSetting(idx.data(BaseId));
|
const Id id = Id::fromSetting(idx.data(BaseId));
|
||||||
settings.frameworks.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
settings.frameworks.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
||||||
idx = model->index(row, 1);
|
idx = model->index(row, 1);
|
||||||
settings.frameworksGrouping.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
settings.frameworksGrouping.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
||||||
@@ -306,7 +308,7 @@ void TestSettingsWidget::testToolsSettings(TestSettings &settings) const
|
|||||||
QTC_ASSERT(row <= end, return);
|
QTC_ASSERT(row <= end, return);
|
||||||
for ( ; row < end; ++row) {
|
for ( ; row < end; ++row) {
|
||||||
const QModelIndex idx = model->index(row, 0);
|
const QModelIndex idx = model->index(row, 0);
|
||||||
const Utils::Id id = Utils::Id::fromSetting(idx.data(BaseId));
|
const Id id = Id::fromSetting(idx.data(BaseId));
|
||||||
settings.tools.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
settings.tools.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,8 +367,8 @@ void TestSettingsPage::apply()
|
|||||||
if (!m_widget) // page was not shown at all
|
if (!m_widget) // page was not shown at all
|
||||||
return;
|
return;
|
||||||
const TestSettings newSettings = m_widget->settings();
|
const TestSettings newSettings = m_widget->settings();
|
||||||
const QList<Utils::Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(),
|
const QList<Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(),
|
||||||
[newSettings, this](const Utils::Id &id) {
|
[newSettings, this](const Id &id) {
|
||||||
return newSettings.frameworksGrouping[id] != m_settings->frameworksGrouping[id];
|
return newSettings.frameworksGrouping[id] != m_settings->frameworksGrouping[id];
|
||||||
});
|
});
|
||||||
*m_settings = newSettings;
|
*m_settings = newSettings;
|
||||||
|
|||||||
@@ -14,16 +14,18 @@
|
|||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
|
|
||||||
static QIcon testTreeIcon(TestTreeItem::Type type)
|
static QIcon testTreeIcon(TestTreeItem::Type type)
|
||||||
{
|
{
|
||||||
static QIcon icons[] = {
|
static QIcon icons[] = {
|
||||||
QIcon(),
|
QIcon(),
|
||||||
Utils::Icons::OPENFILE.icon(),
|
Icons::OPENFILE.icon(),
|
||||||
QIcon(":/autotest/images/suite.png"),
|
QIcon(":/autotest/images/suite.png"),
|
||||||
Utils::CodeModelIcon::iconForType(Utils::CodeModelIcon::Class),
|
CodeModelIcon::iconForType(CodeModelIcon::Class),
|
||||||
Utils::CodeModelIcon::iconForType(Utils::CodeModelIcon::SlotPrivate),
|
CodeModelIcon::iconForType(CodeModelIcon::SlotPrivate),
|
||||||
QIcon(":/autotest/images/data.png")
|
QIcon(":/autotest/images/data.png")
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -33,7 +35,7 @@ static QIcon testTreeIcon(TestTreeItem::Type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ITestTreeItem::ITestTreeItem(ITestBase *testBase, const QString &name,
|
ITestTreeItem::ITestTreeItem(ITestBase *testBase, const QString &name,
|
||||||
const Utils::FilePath &filePath, Type type)
|
const FilePath &filePath, Type type)
|
||||||
: m_testBase(testBase)
|
: m_testBase(testBase)
|
||||||
, m_name(name)
|
, m_name(name)
|
||||||
, m_filePath(filePath)
|
, m_filePath(filePath)
|
||||||
@@ -115,8 +117,8 @@ bool ITestTreeItem::lessThan(const ITestTreeItem *other, ITestTreeItem::SortMode
|
|||||||
Qt::CaseInsensitive) > 0;
|
Qt::CaseInsensitive) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Utils::Link &leftLink = data(0, LinkRole).value<Utils::Link>();
|
const Link &leftLink = data(0, LinkRole).value<Link>();
|
||||||
const Utils::Link &rightLink = other->data(0, LinkRole).value<Utils::Link>();
|
const Link &rightLink = other->data(0, LinkRole).value<Link>();
|
||||||
const int comparison = leftLink.targetFilePath.toString().compare(
|
const int comparison = leftLink.targetFilePath.toString().compare(
|
||||||
rightLink.targetFilePath.toString(), Qt::CaseInsensitive);
|
rightLink.targetFilePath.toString(), Qt::CaseInsensitive);
|
||||||
if (comparison == 0) {
|
if (comparison == 0) {
|
||||||
@@ -144,7 +146,7 @@ ITestConfiguration *ITestTreeItem::asConfiguration(TestRunMode mode) const
|
|||||||
/****************************** TestTreeItem ********************************************/
|
/****************************** TestTreeItem ********************************************/
|
||||||
|
|
||||||
TestTreeItem::TestTreeItem(ITestFramework *testFramework, const QString &name,
|
TestTreeItem::TestTreeItem(ITestFramework *testFramework, const QString &name,
|
||||||
const Utils::FilePath &filePath, Type type)
|
const FilePath &filePath, Type type)
|
||||||
: ITestTreeItem(testFramework, name, filePath, type)
|
: ITestTreeItem(testFramework, name, filePath, type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -168,7 +170,7 @@ QVariant TestTreeItem::data(int column, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
QVariant itemLink;
|
QVariant itemLink;
|
||||||
itemLink.setValue(
|
itemLink.setValue(
|
||||||
Utils::Link(filePath(), line(), int(m_column)));
|
Link(filePath(), line(), int(m_column)));
|
||||||
return itemLink;
|
return itemLink;
|
||||||
}
|
}
|
||||||
return ITestTreeItem::data(column, role);
|
return ITestTreeItem::data(column, role);
|
||||||
@@ -222,7 +224,7 @@ void TestTreeItem::markForRemovalRecursively(bool mark)
|
|||||||
childItem(row)->markForRemovalRecursively(mark);
|
childItem(row)->markForRemovalRecursively(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTreeItem::markForRemovalRecursively(const Utils::FilePath &filepath)
|
void TestTreeItem::markForRemovalRecursively(const FilePath &filepath)
|
||||||
{
|
{
|
||||||
bool mark = filePath() == filepath;
|
bool mark = filePath() == filepath;
|
||||||
forFirstLevelChildItems([&mark, &filepath](TestTreeItem *child) {
|
forFirstLevelChildItems([&mark, &filepath](TestTreeItem *child) {
|
||||||
@@ -249,20 +251,20 @@ TestTreeItem *TestTreeItem::findChildByName(const QString &name)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTreeItem *TestTreeItem::findChildByFile(const Utils::FilePath &filePath)
|
TestTreeItem *TestTreeItem::findChildByFile(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
return findFirstLevelChildItem([filePath](const TestTreeItem *other) {
|
return findFirstLevelChildItem([filePath](const TestTreeItem *other) {
|
||||||
return other->filePath() == filePath;
|
return other->filePath() == filePath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTreeItem *TestTreeItem::findChildByFileAndType(const Utils::FilePath &filePath, Type tType)
|
TestTreeItem *TestTreeItem::findChildByFileAndType(const FilePath &filePath, Type tType)
|
||||||
{
|
{
|
||||||
return findFirstLevelChildItem([filePath, tType](const TestTreeItem *other) {
|
return findFirstLevelChildItem([filePath, tType](const TestTreeItem *other) {
|
||||||
return other->type() == tType && other->filePath() == filePath;
|
return other->type() == tType && other->filePath() == filePath;
|
||||||
});}
|
});}
|
||||||
|
|
||||||
TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const Utils::FilePath &filePath)
|
TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const FilePath &filePath)
|
||||||
{
|
{
|
||||||
return findFirstLevelChildItem([name, filePath](const TestTreeItem *other) {
|
return findFirstLevelChildItem([name, filePath](const TestTreeItem *other) {
|
||||||
return other->filePath() == filePath && other->name() == name;
|
return other->filePath() == filePath && other->name() == name;
|
||||||
@@ -280,7 +282,7 @@ ITestConfiguration *TestTreeItem::asConfiguration(TestRunMode mode) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ITestConfiguration *> TestTreeItem::getTestConfigurationsForFile(const Utils::FilePath &) const
|
QList<ITestConfiguration *> TestTreeItem::getTestConfigurationsForFile(const FilePath &) const
|
||||||
{
|
{
|
||||||
return QList<ITestConfiguration *>();
|
return QList<ITestConfiguration *>();
|
||||||
}
|
}
|
||||||
@@ -342,7 +344,7 @@ void TestTreeItem::copyBasicDataFrom(const TestTreeItem *other)
|
|||||||
m_status = other->m_status;
|
m_status = other->m_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool TestTreeItem::modifyFilePath(const Utils::FilePath &filepath)
|
inline bool TestTreeItem::modifyFilePath(const FilePath &filepath)
|
||||||
{
|
{
|
||||||
if (filePath() != filepath) {
|
if (filePath() != filepath) {
|
||||||
setFilePath(filepath);
|
setFilePath(filepath);
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
|
||||||
using namespace Autotest::Internal;
|
using namespace Autotest::Internal;
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
|
|
||||||
@@ -95,8 +96,7 @@ void TestTreeModel::setupParsingConnections()
|
|||||||
m_parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection);
|
m_parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection);
|
||||||
connect(cppMM, &CppEditor::CppModelManager::aboutToRemoveFiles,
|
connect(cppMM, &CppEditor::CppModelManager::aboutToRemoveFiles,
|
||||||
this, [this](const QStringList &files) {
|
this, [this](const QStringList &files) {
|
||||||
const Utils::FilePaths filesToRemove
|
const FilePaths filesToRemove = FileUtils::toFilePathList(files);
|
||||||
= Utils::FileUtils::toFilePathList(files);
|
|
||||||
removeFiles(filesToRemove);
|
removeFiles(filesToRemove);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
connect(cppMM, &CppEditor::CppModelManager::projectPartsUpdated,
|
connect(cppMM, &CppEditor::CppModelManager::projectPartsUpdated,
|
||||||
@@ -125,7 +125,7 @@ bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||||||
Qt::CheckState checked = item->checked();
|
Qt::CheckState checked = item->checked();
|
||||||
if (item->hasChildren() && checked != Qt::PartiallyChecked) {
|
if (item->hasChildren() && checked != Qt::PartiallyChecked) {
|
||||||
// handle the new checkstate for children as well...
|
// handle the new checkstate for children as well...
|
||||||
for (Utils::TreeItem *child : *item) {
|
for (TreeItem *child : *item) {
|
||||||
const QModelIndex &idx = indexForItem(child);
|
const QModelIndex &idx = indexForItem(child);
|
||||||
setData(idx, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
|
setData(idx, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
|
|||||||
|
|
||||||
bool TestTreeModel::hasTests() const
|
bool TestTreeModel::hasTests() const
|
||||||
{
|
{
|
||||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
for (TreeItem *frameworkRoot : *rootItem()) {
|
||||||
if (frameworkRoot->hasChildren())
|
if (frameworkRoot->hasChildren())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ QList<ITestConfiguration *> TestTreeModel::getFailedTests() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ITestConfiguration *> TestTreeModel::getTestsForFile(const Utils::FilePath &fileName) const
|
QList<ITestConfiguration *> TestTreeModel::getTestsForFile(const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
QList<ITestConfiguration *> result;
|
QList<ITestConfiguration *> result;
|
||||||
forItemsAtLevel<1>([&result, &fileName](ITestTreeItem *testRoot) {
|
forItemsAtLevel<1>([&result, &fileName](ITestTreeItem *testRoot) {
|
||||||
@@ -316,10 +316,10 @@ void TestTreeModel::synchronizeTestFrameworks()
|
|||||||
|
|
||||||
const auto sortedParsers = Utils::transform(sorted, &ITestFramework::testParser);
|
const auto sortedParsers = Utils::transform(sorted, &ITestFramework::testParser);
|
||||||
// pre-check to avoid further processing when frameworks are unchanged
|
// pre-check to avoid further processing when frameworks are unchanged
|
||||||
Utils::TreeItem *invisibleRoot = rootItem();
|
TreeItem *invisibleRoot = rootItem();
|
||||||
QSet<ITestParser *> newlyAdded;
|
QSet<ITestParser *> newlyAdded;
|
||||||
QList<ITestTreeItem *> oldFrameworkRoots;
|
QList<ITestTreeItem *> oldFrameworkRoots;
|
||||||
for (Utils::TreeItem *oldFrameworkRoot : *invisibleRoot)
|
for (TreeItem *oldFrameworkRoot : *invisibleRoot)
|
||||||
oldFrameworkRoots.append(static_cast<ITestTreeItem *>(oldFrameworkRoot));
|
oldFrameworkRoots.append(static_cast<ITestTreeItem *>(oldFrameworkRoot));
|
||||||
|
|
||||||
for (ITestTreeItem *oldFrameworkRoot : oldFrameworkRoots)
|
for (ITestTreeItem *oldFrameworkRoot : oldFrameworkRoots)
|
||||||
@@ -362,10 +362,10 @@ void TestTreeModel::synchronizeTestTools()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pre-check to avoid further processing when test tools are unchanged
|
// pre-check to avoid further processing when test tools are unchanged
|
||||||
Utils::TreeItem *invisibleRoot = rootItem();
|
TreeItem *invisibleRoot = rootItem();
|
||||||
QSet<ITestTool *> newlyAdded;
|
QSet<ITestTool *> newlyAdded;
|
||||||
QList<ITestTreeItem *> oldFrameworkRoots;
|
QList<ITestTreeItem *> oldFrameworkRoots;
|
||||||
for (Utils::TreeItem *oldFrameworkRoot : *invisibleRoot) {
|
for (TreeItem *oldFrameworkRoot : *invisibleRoot) {
|
||||||
auto item = static_cast<ITestTreeItem *>(oldFrameworkRoot);
|
auto item = static_cast<ITestTreeItem *>(oldFrameworkRoot);
|
||||||
if (item->testBase()->type() == ITestBase::Tool)
|
if (item->testBase()->type() == ITestBase::Tool)
|
||||||
oldFrameworkRoots.append(item);
|
oldFrameworkRoots.append(item);
|
||||||
@@ -416,9 +416,9 @@ void TestTreeModel::filterAndInsert(TestTreeItem *item, TestTreeItem *root, bool
|
|||||||
insertItemInParent(filtered, root, groupingEnabled);
|
insertItemInParent(filtered, root, groupingEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTreeModel::rebuild(const QList<Utils::Id> &frameworkIds)
|
void TestTreeModel::rebuild(const QList<Id> &frameworkIds)
|
||||||
{
|
{
|
||||||
for (const Utils::Id &id : frameworkIds) {
|
for (const Id &id : frameworkIds) {
|
||||||
ITestFramework *framework = TestFrameworkManager::frameworkForId(id);
|
ITestFramework *framework = TestFrameworkManager::frameworkForId(id);
|
||||||
TestTreeItem *frameworkRoot = framework->rootNode();
|
TestTreeItem *frameworkRoot = framework->rootNode();
|
||||||
const bool groupingEnabled = framework->grouping();
|
const bool groupingEnabled = framework->grouping();
|
||||||
@@ -456,7 +456,7 @@ void TestTreeModel::updateCheckStateCache()
|
|||||||
|
|
||||||
bool TestTreeModel::hasFailedTests() const
|
bool TestTreeModel::hasFailedTests() const
|
||||||
{
|
{
|
||||||
auto failedItem = rootItem()->findAnyChild([](Utils::TreeItem *it) {
|
auto failedItem = rootItem()->findAnyChild([](TreeItem *it) {
|
||||||
return it->data(0, FailedRole).toBool();
|
return it->data(0, FailedRole).toBool();
|
||||||
});
|
});
|
||||||
return failedItem != nullptr;
|
return failedItem != nullptr;
|
||||||
@@ -464,17 +464,17 @@ bool TestTreeModel::hasFailedTests() const
|
|||||||
|
|
||||||
void TestTreeModel::clearFailedMarks()
|
void TestTreeModel::clearFailedMarks()
|
||||||
{
|
{
|
||||||
for (Utils::TreeItem *rootNode : *rootItem()) {
|
for (TreeItem *rootNode : *rootItem()) {
|
||||||
rootNode->forAllChildren([](Utils::TreeItem *child) {
|
rootNode->forAllChildren([](TreeItem *child) {
|
||||||
child->setData(0, false, FailedRole);
|
child->setData(0, false, FailedRole);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
m_failedStateCache.clear();
|
m_failedStateCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTreeModel::removeFiles(const Utils::FilePaths &files)
|
void TestTreeModel::removeFiles(const FilePaths &files)
|
||||||
{
|
{
|
||||||
for (const Utils::FilePath &file : files)
|
for (const FilePath &file : files)
|
||||||
markForRemoval(file);
|
markForRemoval(file);
|
||||||
sweep();
|
sweep();
|
||||||
}
|
}
|
||||||
@@ -488,7 +488,7 @@ void TestTreeModel::markAllFrameworkItemsForRemoval()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTreeModel::markForRemoval(const Utils::FilePath &filePath)
|
void TestTreeModel::markForRemoval(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
if (filePath.isEmpty())
|
if (filePath.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -558,7 +558,7 @@ static void applyParentCheckState(ITestTreeItem *parent, ITestTreeItem *newItem)
|
|||||||
const Qt::CheckState checkState = parent->checked() == Qt::Unchecked ? Qt::Unchecked
|
const Qt::CheckState checkState = parent->checked() == Qt::Unchecked ? Qt::Unchecked
|
||||||
: Qt::Checked;
|
: Qt::Checked;
|
||||||
newItem->setData(0, checkState, Qt::CheckStateRole);
|
newItem->setData(0, checkState, Qt::CheckStateRole);
|
||||||
newItem->forAllChildren([checkState](Utils::TreeItem *it) {
|
newItem->forAllChildren([checkState](TreeItem *it) {
|
||||||
it->setData(0, checkState, Qt::CheckStateRole);
|
it->setData(0, checkState, Qt::CheckStateRole);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -752,25 +752,25 @@ void TestTreeModel::removeAllTestToolItems()
|
|||||||
// we're inside tests - so use some internal knowledge to make testing easier
|
// we're inside tests - so use some internal knowledge to make testing easier
|
||||||
static TestTreeItem *qtRootNode()
|
static TestTreeItem *qtRootNode()
|
||||||
{
|
{
|
||||||
auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtTest");
|
const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtTest");
|
||||||
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestTreeItem *quickRootNode()
|
static TestTreeItem *quickRootNode()
|
||||||
{
|
{
|
||||||
auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtQuickTest");
|
const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtQuickTest");
|
||||||
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestTreeItem *gtestRootNode()
|
static TestTreeItem *gtestRootNode()
|
||||||
{
|
{
|
||||||
auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("GTest");
|
const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("GTest");
|
||||||
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestTreeItem *boostTestRootNode()
|
static TestTreeItem *boostTestRootNode()
|
||||||
{
|
{
|
||||||
auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("Boost");
|
const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("Boost");
|
||||||
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
return TestFrameworkManager::frameworkForId(id)->rootNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user