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>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Tasking;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Autotest {
|
||||
@@ -55,6 +56,17 @@ TestCodeParser::TestCodeParser()
|
||||
});
|
||||
m_reparseTimer.setSingleShot(true);
|
||||
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;
|
||||
@@ -213,7 +225,7 @@ void TestCodeParser::aboutToShutdown(bool isFinal)
|
||||
qCDebug(LOG) << "Disabling (immediately) -"
|
||||
<< (isFinal ? "shutting down" : "disabled temporarily");
|
||||
m_parserState = isFinal ? Shutdown : DisabledTemporarily;
|
||||
m_taskTree.reset();
|
||||
m_taskTreeRunner.reset();
|
||||
m_futureSynchronizer.waitForFinished();
|
||||
if (!isFinal)
|
||||
onFinished(false);
|
||||
@@ -365,12 +377,11 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
|
||||
return true;
|
||||
return cppSnapshot.contains(fn);
|
||||
});
|
||||
m_withTaskProgress = filteredFiles.size() > 5;
|
||||
|
||||
qCDebug(LOG) << "Starting scan of" << filteredFiles.size() << "(" << files.size() << ")"
|
||||
<< "files with" << codeParsers.size() << "parsers";
|
||||
|
||||
using namespace Tasking;
|
||||
|
||||
int limit = testSettings().scanThreadLimit();
|
||||
if (limit == 0)
|
||||
limit = std::max(QThread::idealThreadCount() / 4, 1);
|
||||
@@ -395,18 +406,7 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
|
||||
LoopRepeat(filteredFiles.size()),
|
||||
AsyncTask<TestParseResultPtr>(onSetup, onDone, CallDoneIf::Success)
|
||||
};
|
||||
m_taskTree.reset(new TaskTree(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();
|
||||
m_taskTreeRunner.start(root);
|
||||
}
|
||||
|
||||
void TestCodeParser::onTaskStarted(Id type)
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
|
||||
#include <solutions/tasking/tasktreerunner.h>
|
||||
|
||||
#include <utils/futuresynchronizer.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
@@ -18,7 +20,6 @@ class QThreadPool;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer { class Project; }
|
||||
namespace Tasking { class TaskTree; }
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
@@ -96,7 +97,8 @@ private:
|
||||
QTimer m_reparseTimer;
|
||||
QSet<ITestParser *> m_updateParsers;
|
||||
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;
|
||||
|
||||
QElapsedTimer m_parsingTimer;
|
||||
|
Reference in New Issue
Block a user