AutoTest: Remove scan filter capability

The scan filter capability had been added to avoid long
scans in bigger projects.
Nowadays the scans are done multi-threaded and the
filtering is probably barely used.

Change-Id: I7d99f5a57bb10deb3d79510db0c7a06bd771c271
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Christian Stenger
2019-03-13 13:13:09 +01:00
parent feb2db61fc
commit 330af3309c
7 changed files with 1 additions and 290 deletions

View File

@@ -240,11 +240,6 @@
\image qtcreator-autotests-options.png
You can add filters to specify the directories within the current project
to scan for tests. Select the \uicontrol {Global Filters} check box, and
then select \uicontrol Add to specify paths to the directories to scan for
tests. Wildcards are not supported in the filter expressions.
In some special setups, \QC cannot deduce which executable or run
configuration it should use. If \QC repeatedly asks you to select the
tests to run when trying to execute tests, you can enable it to cache

View File

@@ -171,28 +171,6 @@ void TestCodeParser::updateTestTree(ITestParser *parser)
scanForTests(QStringList(), parser);
}
static QStringList filterFiles(const QString &projectDir, const QStringList &files)
{
const QSharedPointer<TestSettings> &settings = AutotestPlugin::settings();
const QSet<QString> &filters = settings->whiteListFilters.toSet(); // avoid duplicates
if (!settings->filterScan || filters.isEmpty())
return files;
QStringList finalResult;
for (const QString &file : files) {
// apply filter only below project directory if file is part of a project
const QString &fileToProcess = file.startsWith(projectDir)
? file.mid(projectDir.size())
: file;
for (const QString &filter : filters) {
if (fileToProcess.contains(filter)) {
finalResult.push_back(file);
break;
}
}
}
return finalResult;
}
// used internally to indicate a parse that failed due to having triggered a parse for a file that
// is not (yet) part of the CppModelManager's snapshot
static bool parsingHasFailed;
@@ -379,7 +357,6 @@ void TestCodeParser::scanForTests(const QStringList &fileList, ITestParser *pars
m_model->markForRemoval(filePath);
}
list = filterFiles(project->projectDirectory().toString(), list);
if (list.isEmpty()) {
if (isFullParse) {
Core::MessageManager::instance()->write(

View File

@@ -39,8 +39,6 @@ static const char omitInternalKey[] = "OmitInternal";
static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
static const char limitResultOutputKey[] = "LimitResultOutput";
static const char autoScrollKey[] = "AutoScrollResults";
static const char filterScanKey[] = "FilterScan";
static const char filtersKey[] = "WhiteListFilters";
static const char processArgsKey[] = "ProcessArgs";
static const char displayApplicationKey[] = "DisplayApp";
static const char groupSuffix[] = ".group";
@@ -62,8 +60,6 @@ void TestSettings::toSettings(QSettings *s) const
s->setValue(autoScrollKey, autoScroll);
s->setValue(processArgsKey, processArgs);
s->setValue(displayApplicationKey, displayApplication);
s->setValue(filterScanKey, filterScan);
s->setValue(filtersKey, whiteListFilters);
// store frameworks and their current active and grouping state
for (const Core::Id &id : frameworks.keys()) {
s->setValue(QLatin1String(id.name()), frameworks.value(id));
@@ -82,8 +78,6 @@ void TestSettings::fromSettings(QSettings *s)
autoScroll = s->value(autoScrollKey, true).toBool();
processArgs = s->value(processArgsKey, false).toBool();
displayApplication = s->value(displayApplicationKey, false).toBool();
filterScan = s->value(filterScanKey, false).toBool();
whiteListFilters = s->value(filtersKey, QStringList()).toStringList();
// try to get settings for registered frameworks
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
const QList<Core::Id> &registered = frameworkManager->registeredFrameworkIds();

View File

@@ -47,12 +47,10 @@ struct TestSettings
bool omitRunConfigWarn = false;
bool limitResultOutput = true;
bool autoScroll = true;
bool filterScan = false;
bool processArgs = false;
bool displayApplication = false;
QHash<Core::Id, bool> frameworks;
QHash<Core::Id, bool> frameworksGrouping;
QStringList whiteListFilters;
};
} // namespace Internal

View File

@@ -32,90 +32,12 @@
#include "autotestplugin.h"
#include <coreplugin/icore.h>
#include <utils/fancylineedit.h>
#include <utils/qtcassert.h>
#include <utils/utilsicons.h>
#include <QDialog>
#include <QDialogButtonBox>
#include <QRegExp>
namespace Autotest {
namespace Internal {
class TestFilterDialog : public QDialog
{
public:
explicit TestFilterDialog(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
QString filterPath() const;
void setDetailsText(const QString &details) { m_details->setText(details); }
void setDefaultFilterPath(const QString &defaultPath);
private:
static bool validate(Utils::FancyLineEdit *edit, QString * /*errormessage*/);
QLabel *m_details;
Utils::FancyLineEdit *m_lineEdit;
QString m_defaultPath;
};
TestFilterDialog::TestFilterDialog(QWidget *parent, Qt::WindowFlags f)
: QDialog(parent, f),
m_details(new QLabel),
m_lineEdit(new Utils::FancyLineEdit)
{
setModal(true);
auto layout = new QVBoxLayout(this);
layout->setSizeConstraint(QLayout::SetFixedSize);
layout->addWidget(m_details);
m_lineEdit->setValidationFunction(&validate);
layout->addWidget(m_lineEdit);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
auto cancelButton = buttonBox->button(QDialogButtonBox::Cancel);
okButton->setEnabled(false);
layout->addWidget(buttonBox);
setLayout(layout);
connect(m_lineEdit, &Utils::FancyLineEdit::validChanged, okButton, &QPushButton::setEnabled);
connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
}
QString TestFilterDialog::filterPath() const
{
static const QRegExp repetition("//+");
QString path = m_lineEdit->isValid() ? m_lineEdit->text() : m_defaultPath;
path.replace('\\', '/'); // turn windows separators into forward slashes
path.replace(repetition, "/"); // avoid duplicated separators
if (!path.startsWith('/'))
path.prepend('/');
if (!path.endsWith('/'))
path.append('/');
if (path.length() <= 2) // after surrounding with '/' this should be > 2 if valid
return QString(); // empty string marks invalid filter
return path;
}
void TestFilterDialog::setDefaultFilterPath(const QString &defaultPath)
{
m_lineEdit->setText(defaultPath);
if (m_lineEdit->isValid())
m_defaultPath = defaultPath;
else
m_lineEdit->setText(m_defaultPath);
}
bool TestFilterDialog::validate(Utils::FancyLineEdit *edit, QString *)
{
if (!edit)
return false;
const QString &value = edit->text();
if (value.isEmpty())
return false;
// should we distinguish between Windows and UNIX?
static const QRegExp valid("(\\|/)?([^?*:;\"\'|<>\t\b]+(\\|/)?)+");
return valid.exactMatch(value);
}
/**************************************************************************************************/
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
: QWidget(parent)
{
@@ -129,17 +51,6 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent)
"having at least one active test framework."));
connect(m_ui.frameworkTreeWidget, &QTreeWidget::itemChanged,
this, &TestSettingsWidget::onFrameworkItemChanged);
connect(m_ui.addFilter, &QPushButton::clicked, this, &TestSettingsWidget::onAddFilterClicked);
connect(m_ui.editFilter, &QPushButton::clicked, this, &TestSettingsWidget::onEditFilterClicked);
connect(m_ui.filterTreeWidget, &QTreeWidget::activated,
this, &TestSettingsWidget::onEditFilterClicked);
connect(m_ui.removeFilter, &QPushButton::clicked,
this, &TestSettingsWidget::onRemoveFilterClicked);
connect(m_ui.filterTreeWidget, &QTreeWidget::itemSelectionChanged, [this] () {
const bool enable = m_ui.filterTreeWidget->selectionModel()->hasSelection();
m_ui.editFilter->setEnabled(enable);
m_ui.removeFilter->setEnabled(enable);
});
connect(m_ui.resetChoicesButton, &QPushButton::clicked,
this, [] { AutotestPlugin::clearChoiceCache(); });
}
@@ -153,9 +64,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
m_ui.autoScrollCB->setChecked(settings.autoScroll);
m_ui.processArgsCB->setChecked(settings.processArgs);
m_ui.displayAppCB->setChecked(settings.displayApplication);
m_ui.filterGroupBox->setChecked(settings.filterScan);
populateFrameworksListWidget(settings.frameworks);
populateFiltersWidget(settings.whiteListFilters);
}
TestSettings TestSettingsWidget::settings() const
@@ -168,9 +77,7 @@ TestSettings TestSettingsWidget::settings() const
result.autoScroll = m_ui.autoScrollCB->isChecked();
result.processArgs = m_ui.processArgsCB->isChecked();
result.displayApplication = m_ui.displayAppCB->isChecked();
result.filterScan = m_ui.filterGroupBox->isChecked();
frameworkSettings(result);
result.whiteListFilters = filters();
return result;
}
@@ -196,12 +103,6 @@ void TestSettingsWidget::populateFrameworksListWidget(const QHash<Core::Id, bool
}
}
void TestSettingsWidget::populateFiltersWidget(const QStringList &filters)
{
for (const QString &filter : filters)
new QTreeWidgetItem(m_ui.filterTreeWidget, {filter} );
}
void TestSettingsWidget::frameworkSettings(TestSettings &settings) const
{
const QAbstractItemModel *model = m_ui.frameworkTreeWidget->model();
@@ -216,16 +117,6 @@ void TestSettingsWidget::frameworkSettings(TestSettings &settings) const
}
}
QStringList TestSettingsWidget::filters() const
{
QStringList result;
if (QAbstractItemModel *model = m_ui.filterTreeWidget->model()) {
for (int row = 0, count = model->rowCount(); row < count; ++row)
result.append(model->index(row, 0).data().toString());
}
return result;
}
void TestSettingsWidget::onFrameworkItemChanged()
{
if (QAbstractItemModel *model = m_ui.frameworkTreeWidget->model()) {
@@ -241,45 +132,6 @@ void TestSettingsWidget::onFrameworkItemChanged()
m_ui.frameworksWarnIcon->setVisible(true);
}
void TestSettingsWidget::onAddFilterClicked()
{
TestFilterDialog dialog;
dialog.setWindowTitle(tr("Add Filter"));
dialog.setDetailsText("<p>" + tr("Specify a filter expression to be added to the list of filters."
"<br/>Wildcards are not supported.") + "</p>");
if (dialog.exec() == QDialog::Accepted) {
const QString &filter = dialog.filterPath();
if (!filter.isEmpty())
new QTreeWidgetItem(m_ui.filterTreeWidget, {filter} );
}
}
void TestSettingsWidget::onEditFilterClicked()
{
const QList<QTreeWidgetItem *> &selected = m_ui.filterTreeWidget->selectedItems();
QTC_ASSERT(selected.size() == 1, return);
const QString &oldFilter = selected.first()->data(0, Qt::DisplayRole).toString();
TestFilterDialog dialog;
dialog.setWindowTitle(tr("Edit Filter"));
dialog.setDetailsText("<p>" + tr("Specify a filter expression that will replace \"%1\"."
"<br/>Wildcards are not supported.").arg(oldFilter) + "</p>");
dialog.setDefaultFilterPath(oldFilter);
if (dialog.exec() == QDialog::Accepted) {
const QString &edited = dialog.filterPath();
if (!edited.isEmpty() && edited != oldFilter)
selected.first()->setData(0, Qt::DisplayRole, edited);
}
}
void TestSettingsWidget::onRemoveFilterClicked()
{
const QList<QTreeWidgetItem *> &selected = m_ui.filterTreeWidget->selectedItems();
QTC_ASSERT(selected.size() == 1, return);
m_ui.filterTreeWidget->removeItemWidget(selected.first(), 0);
delete selected.first();
}
TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
: m_settings(settings)
{
@@ -306,8 +158,6 @@ void TestSettingsPage::apply()
return;
const TestSettings newSettings = m_widget->settings();
bool frameworkSyncNecessary = newSettings.frameworks != m_settings->frameworks;
bool forceReparse = newSettings.filterScan != m_settings->filterScan ||
newSettings.whiteListFilters.toSet() != m_settings->whiteListFilters.toSet();
const QList<Core::Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(),
[newSettings, this] (const Core::Id &id) {
return newSettings.frameworksGrouping[id] != m_settings->frameworksGrouping[id];
@@ -318,8 +168,6 @@ void TestSettingsPage::apply()
frameworkManager->activateFrameworksFromSettings(m_settings);
if (frameworkSyncNecessary)
TestTreeModel::instance()->syncTestFrameworks();
else if (forceReparse)
TestTreeModel::instance()->parser()->emitUpdateTestTree();
else if (!changedIds.isEmpty())
TestTreeModel::instance()->rebuild(changedIds);
}

View File

@@ -47,13 +47,8 @@ public:
private:
void populateFrameworksListWidget(const QHash<Core::Id, bool> &frameworks);
void populateFiltersWidget(const QStringList &filters);
void frameworkSettings(TestSettings &settings) const;
QStringList filters() const;
void onFrameworkItemChanged();
void onAddFilterClicked();
void onEditFilterClicked();
void onRemoveFilterClicked();
Ui::TestSettingsPage m_ui;
};

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>585</width>
<height>458</height>
<height>357</height>
</rect>
</property>
<property name="windowTitle">
@@ -283,102 +283,6 @@ Warning: this is an experimental feature and might lead to failing to execute th
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="filterGroupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Global Filters</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QTreeWidget" name="filterTreeWidget">
<property name="toolTip">
<string>Filters used on directories when scanning for tests.&lt;br/&gt;If filtering is enabled, only directories that match any of the filters will be scanned.</string>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="addFilter">
<property name="text">
<string>Add...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editFilter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="removeFilter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">