forked from qt-creator/qt-creator
AutoTest: Reuse TaskTreeRunner for test scanner
Change-Id: I19db6d28c9d68e1394f089b7a58640db153cd7e9 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
@@ -55,6 +56,17 @@ TestCodeParser::TestCodeParser()
|
|||||||
});
|
});
|
||||||
m_reparseTimer.setSingleShot(true);
|
m_reparseTimer.setSingleShot(true);
|
||||||
connect(&m_reparseTimer, &QTimer::timeout, this, &TestCodeParser::parsePostponedFiles);
|
connect(&m_reparseTimer, &QTimer::timeout, this, &TestCodeParser::parsePostponedFiles);
|
||||||
|
connect(&m_taskTreeRunner, &TaskTreeRunner::aboutToStart, this, [this](TaskTree *taskTree) {
|
||||||
|
if (m_withTaskProgress) {
|
||||||
|
auto progress = new TaskProgress(taskTree);
|
||||||
|
progress->setDisplayName(Tr::tr("Scanning for Tests"));
|
||||||
|
progress->setId(Constants::TASK_PARSE);
|
||||||
|
}
|
||||||
|
emit parsingStarted();
|
||||||
|
});
|
||||||
|
connect(&m_taskTreeRunner, &TaskTreeRunner::done, this, [this](DoneWith result) {
|
||||||
|
onFinished(result == DoneWith::Success);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCodeParser::~TestCodeParser() = default;
|
TestCodeParser::~TestCodeParser() = default;
|
||||||
@@ -213,7 +225,7 @@ void TestCodeParser::aboutToShutdown(bool isFinal)
|
|||||||
qCDebug(LOG) << "Disabling (immediately) -"
|
qCDebug(LOG) << "Disabling (immediately) -"
|
||||||
<< (isFinal ? "shutting down" : "disabled temporarily");
|
<< (isFinal ? "shutting down" : "disabled temporarily");
|
||||||
m_parserState = isFinal ? Shutdown : DisabledTemporarily;
|
m_parserState = isFinal ? Shutdown : DisabledTemporarily;
|
||||||
m_taskTree.reset();
|
m_taskTreeRunner.reset();
|
||||||
m_futureSynchronizer.waitForFinished();
|
m_futureSynchronizer.waitForFinished();
|
||||||
if (!isFinal)
|
if (!isFinal)
|
||||||
onFinished(false);
|
onFinished(false);
|
||||||
@@ -365,12 +377,11 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
|
|||||||
return true;
|
return true;
|
||||||
return cppSnapshot.contains(fn);
|
return cppSnapshot.contains(fn);
|
||||||
});
|
});
|
||||||
|
m_withTaskProgress = filteredFiles.size() > 5;
|
||||||
|
|
||||||
qCDebug(LOG) << "Starting scan of" << filteredFiles.size() << "(" << files.size() << ")"
|
qCDebug(LOG) << "Starting scan of" << filteredFiles.size() << "(" << files.size() << ")"
|
||||||
<< "files with" << codeParsers.size() << "parsers";
|
<< "files with" << codeParsers.size() << "parsers";
|
||||||
|
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
int limit = testSettings().scanThreadLimit();
|
int limit = testSettings().scanThreadLimit();
|
||||||
if (limit == 0)
|
if (limit == 0)
|
||||||
limit = std::max(QThread::idealThreadCount() / 4, 1);
|
limit = std::max(QThread::idealThreadCount() / 4, 1);
|
||||||
@@ -395,18 +406,7 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
|
|||||||
LoopRepeat(filteredFiles.size()),
|
LoopRepeat(filteredFiles.size()),
|
||||||
AsyncTask<TestParseResultPtr>(onSetup, onDone, CallDoneIf::Success)
|
AsyncTask<TestParseResultPtr>(onSetup, onDone, CallDoneIf::Success)
|
||||||
};
|
};
|
||||||
m_taskTree.reset(new TaskTree(root));
|
m_taskTreeRunner.start(root);
|
||||||
connect(m_taskTree.get(), &TaskTree::started, this, &TestCodeParser::parsingStarted);
|
|
||||||
connect(m_taskTree.get(), &TaskTree::done, this, [this](DoneWith result) {
|
|
||||||
m_taskTree.release()->deleteLater();
|
|
||||||
onFinished(result == DoneWith::Success);
|
|
||||||
});
|
|
||||||
if (filteredFiles.size() > 5) {
|
|
||||||
auto progress = new TaskProgress(m_taskTree.get());
|
|
||||||
progress->setDisplayName(Tr::tr("Scanning for Tests"));
|
|
||||||
progress->setId(Constants::TASK_PARSE);
|
|
||||||
}
|
|
||||||
m_taskTree->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCodeParser::onTaskStarted(Id type)
|
void TestCodeParser::onTaskStarted(Id type)
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <qmljs/qmljsdocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
|
||||||
|
#include <solutions/tasking/tasktreerunner.h>
|
||||||
|
|
||||||
#include <utils/futuresynchronizer.h>
|
#include <utils/futuresynchronizer.h>
|
||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
|
|
||||||
@@ -18,7 +20,6 @@ class QThreadPool;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer { class Project; }
|
namespace ProjectExplorer { class Project; }
|
||||||
namespace Tasking { class TaskTree; }
|
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -96,7 +97,8 @@ private:
|
|||||||
QTimer m_reparseTimer;
|
QTimer m_reparseTimer;
|
||||||
QSet<ITestParser *> m_updateParsers;
|
QSet<ITestParser *> m_updateParsers;
|
||||||
Utils::FutureSynchronizer m_futureSynchronizer;
|
Utils::FutureSynchronizer m_futureSynchronizer;
|
||||||
std::unique_ptr<Tasking::TaskTree> m_taskTree;
|
Tasking::TaskTreeRunner m_taskTreeRunner;
|
||||||
|
bool m_withTaskProgress = false;
|
||||||
QHash<Utils::FilePath, int> m_qmlEditorRev;
|
QHash<Utils::FilePath, int> m_qmlEditorRev;
|
||||||
|
|
||||||
QElapsedTimer m_parsingTimer;
|
QElapsedTimer m_parsingTimer;
|
||||||
|
Reference in New Issue
Block a user