forked from qt-creator/qt-creator
AutoTest: Use working copy of own parser
In TestCodeParser::syncTestFrameworks(), a parser is created for every test framework. As a result, the last parser being created would "win" the global s_parserInstance variable, which is not predictable and probably not intended. So turn CppParser::getFileContent() into a non- static method, avoiding the global variable altogether. Change-Id: I9f7560f1185bc4a3bc7b2b36e89280351998465e Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -115,11 +115,13 @@ static BoostTestParseResult *createParseResult(const QString &name, const QStrin
|
||||
|
||||
}
|
||||
|
||||
static bool handleBoostTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const CPlusPlus::Document::Ptr &doc,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
ITestBase *base)
|
||||
bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName)
|
||||
{
|
||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||
if (doc.isNull() || !includesBoostTest(doc, m_cppSnapshot) || !hasBoostTestMacros(doc))
|
||||
return false;
|
||||
|
||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||
const QString &filePath = doc->fileName();
|
||||
|
||||
@@ -128,9 +130,9 @@ static bool handleBoostTest(QFutureInterface<TestParseResultPtr> futureInterface
|
||||
return false;
|
||||
const CppTools::ProjectPart::Ptr projectPart = projectParts.first();
|
||||
const auto projectFile = projectPart->projectFile;
|
||||
const QByteArray &fileContent = CppParser::getFileContent(filePath);
|
||||
const QByteArray &fileContent = getFileContent(filePath);
|
||||
|
||||
BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, snapshot);
|
||||
BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot);
|
||||
const BoostTestCodeLocationList foundTests = codeParser.findTests();
|
||||
if (foundTests.isEmpty())
|
||||
return false;
|
||||
@@ -140,7 +142,7 @@ static bool handleBoostTest(QFutureInterface<TestParseResultPtr> futureInterface
|
||||
BoostTestInfo firstSuite = suitesStates.first();
|
||||
QStringList suites = firstSuite.fullName.split('/');
|
||||
BoostTestParseResult *topLevelSuite = createParseResult(suites.first(), filePath,
|
||||
projectFile, base,
|
||||
projectFile, framework(),
|
||||
TestTreeItem::TestSuite,
|
||||
firstSuite);
|
||||
BoostTestParseResult *currentSuite = topLevelSuite;
|
||||
@@ -149,7 +151,7 @@ static bool handleBoostTest(QFutureInterface<TestParseResultPtr> futureInterface
|
||||
firstSuite = suitesStates.first();
|
||||
suites = firstSuite.fullName.split('/');
|
||||
BoostTestParseResult *suiteResult = createParseResult(suites.last(), filePath,
|
||||
projectFile, base,
|
||||
projectFile, framework(),
|
||||
TestTreeItem::TestSuite,
|
||||
firstSuite);
|
||||
currentSuite->children.append(suiteResult);
|
||||
@@ -162,7 +164,7 @@ static bool handleBoostTest(QFutureInterface<TestParseResultPtr> futureInterface
|
||||
locationAndType.m_suitesState.last().fullName + "::" + locationAndType.m_name,
|
||||
locationAndType.m_state, locationAndType.m_line};
|
||||
BoostTestParseResult *funcResult = createParseResult(locationAndType.m_name, filePath,
|
||||
projectFile, base,
|
||||
projectFile, framework(),
|
||||
locationAndType.m_type,
|
||||
tmpInfo);
|
||||
currentSuite->children.append(funcResult);
|
||||
@@ -172,14 +174,5 @@ static bool handleBoostTest(QFutureInterface<TestParseResultPtr> futureInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInterface,
|
||||
const QString &fileName)
|
||||
{
|
||||
CPlusPlus::Document::Ptr doc = document(fileName);
|
||||
if (doc.isNull() || !includesBoostTest(doc, m_cppSnapshot) || !hasBoostTestMacros(doc))
|
||||
return false;
|
||||
return handleBoostTest(futureInterface, doc, m_cppSnapshot, framework());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
||||
Reference in New Issue
Block a user