diff options
author | Bernhard Beschow <shentey@gmail.com> | 2021-01-01 19:19:10 +0100 |
---|---|---|
committer | Bernhard Beschow <shentey@gmail.com> | 2021-01-22 10:51:53 +0000 |
commit | 5d7f2d7444e3542cfece720aa6f81be741eb6d26 (patch) | |
tree | e847a9566826e31cf1e5248fc67c466d70dae586 /src/plugins/autotest/quick/quicktestparser.cpp | |
parent | d8c1e51bfeafa4498e3c0ef3738c36897a37ece4 (diff) | |
download | qt-creator-5d7f2d7444e3542cfece720aa6f81be741eb6d26.tar.gz |
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>
Diffstat (limited to 'src/plugins/autotest/quick/quicktestparser.cpp')
-rw-r--r-- | src/plugins/autotest/quick/quicktestparser.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp index 151d2f35c8..828fa77ad6 100644 --- a/src/plugins/autotest/quick/quicktestparser.cpp +++ b/src/plugins/autotest/quick/quicktestparser.cpp @@ -112,8 +112,7 @@ static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM, return QString(); } -static QString quickTestName(const CPlusPlus::Document::Ptr &doc, - const CPlusPlus::Snapshot &snapshot) +QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const { const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses(); @@ -123,20 +122,20 @@ static QString quickTestName(const CPlusPlus::Document::Ptr &doc, const QByteArray name = macro.macro().name(); if (QuickTestUtils::isQuickTestMacro(name)) { CPlusPlus::Document::Block arg = macro.arguments().at(0); - return QLatin1String(CppParser::getFileContent(doc->fileName()) + return QLatin1String(getFileContent(doc->fileName()) .mid(int(arg.bytesBegin()), int(arg.bytesEnd() - arg.bytesBegin()))); } } // check for using quick_test_main() directly const QString fileName = doc->fileName(); - const QByteArray &fileContent = CppParser::getFileContent(fileName); - CPlusPlus::Document::Ptr document = snapshot.preprocessedDocument(fileContent, fileName); + const QByteArray &fileContent = getFileContent(fileName); + CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName); if (document.isNull()) return QString(); document->check(); CPlusPlus::AST *ast = document->translationUnit()->ast(); - QuickTestAstVisitor astVisitor(document, snapshot); + QuickTestAstVisitor astVisitor(document, m_cppSnapshot); astVisitor.accept(ast); return astVisitor.testBaseName(); } @@ -233,7 +232,7 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> fut ITestFramework *framework) { const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance(); - if (quickTestName(document, m_cppSnapshot).isEmpty()) + if (quickTestName(document).isEmpty()) return false; const QString cppFileName = document->fileName(); |