forked from qt-creator/qt-creator
AutoTest: Ensure that removing and adding qml files is noticed
Task-number: QTCREATORBUG-17805 Change-Id: I068f6925fc39813a504205c4ef8e8b9f9e911189 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -28,16 +28,22 @@
|
||||
#include "quicktestvisitors.h"
|
||||
#include "quicktest_utils.h"
|
||||
#include "../autotest_utils.h"
|
||||
#include "../testcodeparser.h"
|
||||
|
||||
#include <projectexplorer/session.h>
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljs/qmljsdialect.h>
|
||||
#include <qmljstools/qmljsmodelmanager.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
static QFileSystemWatcher s_directoryWatcher;
|
||||
|
||||
TestTreeItem *QuickTestParseResult::createTestTreeItem() const
|
||||
{
|
||||
if (itemType == TestTreeItem::Root || itemType == TestTreeItem::TestDataTag)
|
||||
@@ -140,6 +146,8 @@ static QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QStri
|
||||
QFileInfo fi(it.fileInfo().canonicalFilePath());
|
||||
dirs << fi.filePath();
|
||||
}
|
||||
s_directoryWatcher.addPaths(dirs);
|
||||
|
||||
QList<QmlJS::Document::Ptr> foundDocs;
|
||||
|
||||
for (const QString &path : dirs) {
|
||||
@@ -227,6 +235,27 @@ static bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterfa
|
||||
return result;
|
||||
}
|
||||
|
||||
QuickTestParser::QuickTestParser()
|
||||
: CppParser()
|
||||
{
|
||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||
&ProjectExplorer::SessionManager::startupProjectChanged, [] {
|
||||
const QStringList &dirs = s_directoryWatcher.directories();
|
||||
if (!dirs.isEmpty())
|
||||
s_directoryWatcher.removePaths(dirs);
|
||||
});
|
||||
QObject::connect(&s_directoryWatcher, &QFileSystemWatcher::directoryChanged,
|
||||
[this] { TestTreeModel::instance()->parser()->emitUpdateTestTree(this); });
|
||||
}
|
||||
|
||||
QuickTestParser::~QuickTestParser()
|
||||
{
|
||||
QObject::disconnect(&s_directoryWatcher, 0, 0, 0);
|
||||
const QStringList &dirs = s_directoryWatcher.directories();
|
||||
if (!dirs.isEmpty())
|
||||
s_directoryWatcher.removePaths(dirs);
|
||||
}
|
||||
|
||||
void QuickTestParser::init(const QStringList &filesToParse)
|
||||
{
|
||||
m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot();
|
||||
|
||||
Reference in New Issue
Block a user