forked from qt-creator/qt-creator
AutoTest: Extract helper function for re-use
Change-Id: I38993e28090ff68803bfc417d1590e1b2eb97bbe Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -472,6 +472,21 @@ void popupResultsPane()
|
||||
dd->m_resultsPane->popup(Core::IOutputPane::NoModeSwitch);
|
||||
}
|
||||
|
||||
QString wildcardPatternFromString(const QString &original)
|
||||
{
|
||||
QString pattern = original;
|
||||
pattern.replace('\\', "\\\\");
|
||||
pattern.replace('.', "\\.");
|
||||
pattern.replace('^', "\\^").replace('$', "\\$");
|
||||
pattern.replace('(', "\\(").replace(')', "\\)");
|
||||
pattern.replace('[', "\\[").replace(']', "\\]");
|
||||
pattern.replace('{', "\\{").replace('}', "\\}");
|
||||
pattern.replace('+', "\\+");
|
||||
pattern.replace('*', ".*");
|
||||
pattern.replace('?', '.');
|
||||
return pattern;
|
||||
}
|
||||
|
||||
bool ChoicePair::matches(const ProjectExplorer::RunConfiguration *rc) const
|
||||
{
|
||||
return rc && rc->displayName() == displayName && rc->runnable().command.executable() == executable;
|
||||
|
||||
@@ -33,6 +33,6 @@ void cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choic
|
||||
ChoicePair cachedChoiceFor(const QString &buildTargetKey);
|
||||
void clearChoiceCache();
|
||||
void popupResultsPane();
|
||||
|
||||
QString wildcardPatternFromString(const QString &original);
|
||||
|
||||
} // Autotest::Internal
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "gtestframework.h"
|
||||
#include "gtestparser.h"
|
||||
#include "../autotesttr.h"
|
||||
#include "../autotestplugin.h"
|
||||
|
||||
#include <cppeditor/cppmodelmanager.h>
|
||||
|
||||
@@ -56,20 +57,6 @@ TestTreeItem *GTestTreeItem::copyWithoutChildren()
|
||||
return copied;
|
||||
}
|
||||
|
||||
static QString wildCardPattern(const QString &original)
|
||||
{
|
||||
QString pattern = original;
|
||||
pattern.replace('.', "\\.");
|
||||
pattern.replace('$', "\\$");
|
||||
pattern.replace('(', "\\(").replace(')', "\\)");
|
||||
pattern.replace('[', "\\[").replace(']', "\\]");
|
||||
pattern.replace('{', "\\{").replace('}', "\\}");
|
||||
pattern.replace('+', "\\+");
|
||||
pattern.replace('*', ".*");
|
||||
pattern.replace('?', '.');
|
||||
return pattern;
|
||||
}
|
||||
|
||||
static bool matchesFilter(const QString &filter, const QString &fullTestName)
|
||||
{
|
||||
QStringList positive;
|
||||
@@ -87,12 +74,12 @@ static bool matchesFilter(const QString &filter, const QString &fullTestName)
|
||||
testName.append('.');
|
||||
|
||||
for (const QString &curr : negative) {
|
||||
QRegularExpression regex(wildCardPattern(curr));
|
||||
QRegularExpression regex(wildcardPatternFromString(curr));
|
||||
if (regex.match(testName).hasMatch())
|
||||
return false;
|
||||
}
|
||||
for (const QString &curr : positive) {
|
||||
QRegularExpression regex(wildCardPattern(curr));
|
||||
QRegularExpression regex(wildcardPatternFromString(curr));
|
||||
if (regex.match(testName).hasMatch())
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user