AutoTest: Provide way to remember last chosen run configurations

In some special setups it is almost impossible to get the right
executable or run configuration. For bigger projects this can
become a pain point when trying to execute tests and always
getting asked which one to run.
So, allow remembering the choice and use it if appropriate.
The cached information is not stored permanently.

Resetting of the cached information can also be triggered by
switching or closing the current project and inside the settings.

Task-number: QTCREATORBUG-20859
Change-Id: If416ea0ae9ad3548daca2ffcf5888fd568fd2622
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2018-08-08 12:40:03 +02:00
parent 8d814facf7
commit bab836c009
6 changed files with 102 additions and 1 deletions

View File

@@ -49,6 +49,7 @@
#include <utils/outputformat.h>
#include <utils/qtcprocess.h>
#include <QCheckBox>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QFormLayout>
@@ -365,6 +366,17 @@ static ProjectExplorer::RunConfiguration *getRunConfiguration(const QString &bui
= Utils::filtered(target->runConfigurations(), [] (const RunConfiguration *rc) {
return !rc->runnable().executable.isEmpty();
});
const ChoicePair oldChoice = AutotestPlugin::cachedChoiceFor(buildTargetKey);
if (!oldChoice.executable.isEmpty()) {
runConfig = Utils::findOrDefault(runConfigurations,
[&oldChoice] (const RunConfiguration *rc) {
return oldChoice.matches(rc);
});
if (runConfig)
return runConfig;
}
if (runConfigurations.size() == 1)
return runConfigurations.first();
@@ -380,6 +392,8 @@ static ProjectExplorer::RunConfiguration *getRunConfiguration(const QString &bui
return false;
return rc->runnable().executable == exe;
});
if (runConfig && dialog.rememberChoice())
AutotestPlugin::cacheRunConfigChoice(buildTargetKey, ChoicePair(dName, exe));
}
return runConfig;
}
@@ -669,6 +683,8 @@ RunConfigurationSelectionDialog::RunConfigurationSelectionDialog(const QString &
details.append(QString(" (%1)").arg(buildTargetKey));
m_details = new QLabel(details, this);
m_rcCombo = new QComboBox(this);
m_rememberCB = new QCheckBox(tr("Remember choice. Cached choices can be reset by switching "
"projects or using the option to clear the cache."), this);
m_executable = new QLabel(this);
m_arguments = new QLabel(this);
m_workingDir = new QLabel(this);
@@ -680,6 +696,7 @@ RunConfigurationSelectionDialog::RunConfigurationSelectionDialog(const QString &
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
formLayout->addRow(m_details);
formLayout->addRow(tr("Run Configuration:"), m_rcCombo);
formLayout->addRow(m_rememberCB);
formLayout->addRow(createLine(this));
formLayout->addRow(tr("Executable:"), m_executable);
formLayout->addRow(tr("Arguments:"), m_arguments);
@@ -709,6 +726,11 @@ QString RunConfigurationSelectionDialog::executable() const
return m_executable ? m_executable->text() : QString();
}
bool RunConfigurationSelectionDialog::rememberChoice() const
{
return m_rememberCB ? m_rememberCB->isChecked() : false;
}
void RunConfigurationSelectionDialog::populate()
{
m_rcCombo->addItem(QString(), QStringList({QString(), QString(), QString()})); // empty default