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:
Christian Stenger
2018-02-28 09:42:13 +01:00
parent 070b5fdbbb
commit aee959ea1d
15 changed files with 343 additions and 23 deletions

View File

@@ -25,6 +25,7 @@
#include "gtest_utils.h"
#include <QRegularExpression>
#include <QStringList>
namespace Autotest {
@@ -51,6 +52,17 @@ bool isGTestTyped(const QString &macro)
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