forked from qt-creator/qt-creator
AutoTest: Add gtest filter mode
This adds another grouping mode to the gtest framework based on gtest filtering. You can now specify a filter that will be used to group the gtest tree items into matching and non-matching tests. Change-Id: Iaf0e55c9e57e2720f4fa84ab4b51ecaeb614df88 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "gtest_utils.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
|
||||
namespace Autotest {
|
||||
@@ -51,6 +52,17 @@ bool isGTestTyped(const QString ¯o)
|
||||
return macro == QStringLiteral("TYPED_TEST") || macro == QStringLiteral("TYPED_TEST_P");
|
||||
}
|
||||
|
||||
bool isValidGTestFilter(const QString &filterExpression)
|
||||
{
|
||||
// this still is not a 100% validation - but a compromise
|
||||
// - numbers after '.' should get prohibited
|
||||
// - more than one '.' inside a single filter should be prohibited
|
||||
static const QRegularExpression regex("^(:*([_a-zA-Z*.?][_a-zA-Z0-9*.?]*:*)*)?"
|
||||
"(-(:*([_a-zA-Z*.?][_a-zA-Z0-9*.?]*:*)*)?)?$");
|
||||
|
||||
return regex.match(filterExpression).hasMatch();
|
||||
}
|
||||
|
||||
} // namespace GTestUtils
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
||||
Reference in New Issue
Block a user