Fix detection of disabled gtests

Change-Id: Id5df61d332963f0a94d1f292e4da926faa6e2679
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
Christian Stenger
2016-01-19 10:50:10 +01:00
parent ab8970f0ef
commit 180064f8de

View File

@@ -353,6 +353,7 @@ GTestVisitor::GTestVisitor(CPlusPlus::Document::Ptr doc)
bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast) bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
{ {
static QString disabledPrefix = QString::fromLatin1("DISABLED_");
if (!ast || !ast->declarator || !ast->declarator->core_declarator) if (!ast || !ast->declarator || !ast->declarator->core_declarator)
return false; return false;
@@ -371,7 +372,8 @@ bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
const QString &testCaseName = m_overview.prettyType(testCaseNameArg->type()); const QString &testCaseName = m_overview.prettyType(testCaseNameArg->type());
const QString &testName = m_overview.prettyType(testNameArg->type()); const QString &testName = m_overview.prettyType(testNameArg->type());
bool disabled = testName.startsWith(QLatin1String("DISABLED_")); const bool disabled = testName.startsWith(disabledPrefix);
const bool disabledCase = testCaseName.startsWith(disabledPrefix);
unsigned line = 0; unsigned line = 0;
unsigned column = 0; unsigned column = 0;
unsigned token = id->firstToken(); unsigned token = id->firstToken();
@@ -382,9 +384,10 @@ bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
locationAndType.m_line = line; locationAndType.m_line = line;
locationAndType.m_column = column - 1; locationAndType.m_column = column - 1;
locationAndType.m_type = TestTreeItem::GTestName; locationAndType.m_type = TestTreeItem::GTestName;
locationAndType.m_state = disabled ? TestTreeItem::Disabled : TestTreeItem::Enabled; locationAndType.m_state = (disabled || disabledCase) ? TestTreeItem::Disabled
: TestTreeItem::Enabled;
GTestCaseSpec spec; GTestCaseSpec spec;
spec.testCaseName = testCaseName; spec.testCaseName = disabledCase ? testCaseName.mid(9) : testCaseName;
spec.parameterized = TestUtils::isGTestParameterized(prettyName); spec.parameterized = TestUtils::isGTestParameterized(prettyName);
m_gtestFunctions[spec].append(locationAndType); m_gtestFunctions[spec].append(locationAndType);
} }