From 36caa1f292ddfd45b877d331e6d68f813563d259 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 22 Jul 2020 14:54:08 +0200 Subject: Replace QRegExp by QRegularExpression Change-Id: I6c86565b8464efd0b7aec61c12879d3b95a5871c Reviewed-by: Christian Kandeler --- src/app/qbs-create-project/createproject.cpp | 8 +++--- src/app/qbs-create-project/createproject.h | 6 ++--- src/app/qbs/status.cpp | 36 ++++++++++++++------------ src/lib/corelib/api/project.cpp | 4 +-- src/lib/corelib/language/language.cpp | 6 ++--- src/lib/corelib/language/language.h | 6 ++--- src/lib/corelib/language/projectresolver.cpp | 10 +++---- src/lib/corelib/tools/codelocation.cpp | 6 ++--- src/lib/corelib/tools/fileinfo.cpp | 13 +--------- src/lib/corelib/tools/fileinfo.h | 1 - src/lib/corelib/tools/jsliterals.cpp | 4 +-- src/lib/corelib/tools/persistence.cpp | 2 +- src/lib/corelib/tools/persistence.h | 14 +++++++--- src/lib/corelib/tools/shellutils.cpp | 8 +++--- src/lib/corelib/tools/version.cpp | 15 ++++++----- tests/auto/blackbox/tst_blackbox.cpp | 36 +++++++++++++++----------- tests/auto/blackbox/tst_clangdb.cpp | 8 +++--- tests/auto/cmdlineparser/tst_cmdlineparser.cpp | 1 - tests/auto/language/tst_language.cpp | 3 ++- 19 files changed, 97 insertions(+), 90 deletions(-) diff --git a/src/app/qbs-create-project/createproject.cpp b/src/app/qbs-create-project/createproject.cpp index 26147b484..20338be98 100644 --- a/src/app/qbs-create-project/createproject.cpp +++ b/src/app/qbs-create-project/createproject.cpp @@ -62,9 +62,9 @@ void ProjectCreator::run(const QString &topLevelDir, ProjectStructure projectStr { m_projectStructure = projectStructure; for (const QString &s : whiteList) - m_whiteList.push_back(QRegExp(s, Qt::CaseSensitive, QRegExp::Wildcard)); + m_whiteList.push_back(QRegularExpression(QRegularExpression::wildcardToRegularExpression(s))); for (const QString &s : blackList) - m_blackList.push_back(QRegExp(s, Qt::CaseSensitive, QRegExp::Wildcard)); + m_blackList.push_back(QRegularExpression(QRegularExpression::wildcardToRegularExpression(s))); m_topLevelProject.dirPath = topLevelDir; setupProject(&m_topLevelProject); serializeProject(m_topLevelProject); @@ -162,7 +162,9 @@ void ProjectCreator::addGroups(QTextStream &stream, const QDir &baseDir, bool ProjectCreator::isSourceFile(const QString &fileName) { - const auto isMatch = [fileName](const QRegExp &rex) { return rex.exactMatch(fileName); }; + const auto isMatch = [fileName](const QRegularExpression &rex) { + return rex.match(fileName).hasMatch(); + }; return !std::any_of(m_blackList.cbegin(), m_blackList.cend(), isMatch) && (m_whiteList.empty() || std::any_of(m_whiteList.cbegin(), m_whiteList.cend(), isMatch)); diff --git a/src/app/qbs-create-project/createproject.h b/src/app/qbs-create-project/createproject.h index efc217b68..ac7d53e1a 100644 --- a/src/app/qbs-create-project/createproject.h +++ b/src/app/qbs-create-project/createproject.h @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include @@ -83,8 +83,8 @@ private: }; Project m_topLevelProject; ProjectStructure m_projectStructure = ProjectStructure::Flat; - QList m_whiteList; - QList m_blackList; + QList m_whiteList; + QList m_blackList; }; #endif // QBS_CREATEPROJECT_H diff --git a/src/app/qbs/status.cpp b/src/app/qbs/status.cpp index 01d3451fe..a5e0c8228 100644 --- a/src/app/qbs/status.cpp +++ b/src/app/qbs/status.cpp @@ -47,20 +47,20 @@ #include #include #include +#include #include -#include namespace qbs { -static QList createIgnoreList(const QString &projectRootPath) +static QList createIgnoreList(const QString &projectRootPath) { - QList ignoreRegularExpressionList { - QRegExp(projectRootPath + QLatin1String("/build.*")), - QRegExp(QStringLiteral("*.qbs"), Qt::CaseSensitive, QRegExp::Wildcard), - QRegExp(QStringLiteral("*.pro"), Qt::CaseSensitive, QRegExp::Wildcard), - QRegExp(QStringLiteral("*Makefile"), Qt::CaseSensitive, QRegExp::Wildcard), - QRegExp(QStringLiteral("*.so*"), Qt::CaseSensitive, QRegExp::Wildcard), - QRegExp(QStringLiteral("*.o"), Qt::CaseSensitive, QRegExp::Wildcard) + QList ignoreRegularExpressionList { + QRegularExpression(QRegularExpression::anchoredPattern(projectRootPath + QLatin1String("/build.*"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.qbs"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.pro"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*Makefile"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.so*"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.o"))) }; QString ignoreFilePath = projectRootPath + QLatin1String("/.qbsignore"); @@ -71,11 +71,12 @@ static QList createIgnoreList(const QString &projectRootPath) for (const QByteArray &btoken : ignoreTokenList) { const QString token = QString::fromLatin1(btoken); if (token.startsWith(QLatin1String("/"))) - ignoreRegularExpressionList.push_back(QRegExp(projectRootPath - + token + QLatin1String(".*"), - Qt::CaseSensitive, QRegExp::RegExp2)); + ignoreRegularExpressionList.push_back( + QRegularExpression(QRegularExpression::anchoredPattern( + projectRootPath + token + QLatin1String(".*")))); else if (!token.isEmpty()) - ignoreRegularExpressionList.push_back(QRegExp(token, Qt::CaseSensitive, QRegExp::RegExp2)); + ignoreRegularExpressionList.push_back( + QRegularExpression(QRegularExpression::anchoredPattern(token))); } } @@ -83,7 +84,8 @@ static QList createIgnoreList(const QString &projectRootPath) return ignoreRegularExpressionList; } -static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const QList &ignoreRegularExpressionList) +static QStringList allFilesInDirectoryRecursive( + const QDir &rootDirecory, const QList &ignoreRegularExpressionList) { QStringList fileList; @@ -91,8 +93,8 @@ static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const for (const QFileInfo &fileInfo : fileInfos) { QString absoluteFilePath = fileInfo.absoluteFilePath(); bool inIgnoreList = false; - for (const QRegExp &ignoreRegularExpression : ignoreRegularExpressionList) { - if (ignoreRegularExpression.exactMatch(absoluteFilePath)) { + for (const QRegularExpression &ignoreRegularExpression : ignoreRegularExpressionList) { + if (ignoreRegularExpression.match(absoluteFilePath).hasMatch()) { inIgnoreList = true; break; } @@ -112,7 +114,7 @@ static QStringList allFilesInDirectoryRecursive(const QDir &rootDirecory, const static QStringList allFilesInProject(const QString &projectRootPath) { - QList ignoreRegularExpressionList = createIgnoreList(projectRootPath); + QList ignoreRegularExpressionList = createIgnoreList(projectRootPath); return allFilesInDirectoryRecursive(QDir(projectRootPath), ignoreRegularExpressionList); } diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp index f7a9eca09..e6caf1b2b 100644 --- a/src/lib/corelib/api/project.cpp +++ b/src/lib/corelib/api/project.cpp @@ -82,7 +82,7 @@ #include #include -#include +#include #include #include @@ -414,7 +414,7 @@ static bool matchesWildcard(const QString &filePath, const GroupConstPtr &group) } fullPattern.append(QLatin1Char('/')).append(pattern); fullPattern = QDir::cleanPath(fullPattern); - if (QRegExp(fullPattern, Qt::CaseSensitive, QRegExp::Wildcard).exactMatch(filePath)) + if (QRegularExpression(QRegularExpression::wildcardToRegularExpression(fullPattern)).match(filePath).hasMatch()) return true; } return false; diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index 7b21bc12a..0b472a668 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -102,7 +102,7 @@ void FileTagger::setPatterns(const QStringList &patterns) m_patterns.clear(); for (const QString &pattern : patterns) { QBS_CHECK(!pattern.isEmpty()); - m_patterns << QRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard); + m_patterns << QRegularExpression(QRegularExpression::wildcardToRegularExpression(pattern)); } } @@ -347,8 +347,8 @@ FileTags ResolvedProduct::fileTagsForFileName(const QString &fileName) const FileTags result; std::unique_ptr priority; for (const FileTaggerConstPtr &tagger : qAsConst(fileTaggers)) { - for (const QRegExp &pattern : tagger->patterns()) { - if (FileInfo::globMatches(pattern, fileName)) { + for (const QRegularExpression &pattern : tagger->patterns()) { + if (pattern.match(fileName).hasMatch()) { if (priority) { if (*priority != tagger->priority()) { // The taggers are expected to be sorted by priority. diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h index bbd851333..23a5f1d1a 100644 --- a/src/lib/corelib/language/language.h +++ b/src/lib/corelib/language/language.h @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include @@ -88,7 +88,7 @@ public: return FileTaggerPtr(new FileTagger(patterns, fileTags, priority)); } - const QList &patterns() const { return m_patterns; } + const QList &patterns() const { return m_patterns; } const FileTags &fileTags() const { return m_fileTags; } int priority() const { return m_priority; } @@ -103,7 +103,7 @@ private: void setPatterns(const QStringList &patterns); - QList m_patterns; + QList m_patterns; FileTags m_fileTags; int m_priority = 0; }; diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp index fd6063381..4e8e94b4e 100644 --- a/src/lib/corelib/language/projectresolver.cpp +++ b/src/lib/corelib/language/projectresolver.cpp @@ -68,7 +68,7 @@ #include #include -#include +#include #include #include @@ -1052,12 +1052,12 @@ void ProjectResolver::setupExportedProperties(const Item *item, const QString &n std::sort(properties.begin(), properties.end(), less); } -static bool usesImport(const ExportedProperty &prop, const QRegExp ®ex) +static bool usesImport(const ExportedProperty &prop, const QRegularExpression ®ex) { - return regex.indexIn(prop.sourceCode) != -1; + return prop.sourceCode.indexOf(regex) != -1; } -static bool usesImport(const ExportedItem &item, const QRegExp ®ex) +static bool usesImport(const ExportedItem &item, const QRegularExpression ®ex) { return any_of(item.properties, [regex](const ExportedProperty &p) { return usesImport(p, regex); }) @@ -1073,7 +1073,7 @@ static bool usesImport(const ExportedModule &module, const QString &name) // (3) var obj = DataCollection; const QString pattern = QStringLiteral("\\b%1\\b"); - const QRegExp regex(pattern.arg(name)); // std::regex is much slower + const QRegularExpression regex(pattern.arg(name)); // std::regex is much slower return any_of(module.m_properties, [regex](const ExportedProperty &p) { return usesImport(p, regex); }) || any_of(module.children, diff --git a/src/lib/corelib/tools/codelocation.cpp b/src/lib/corelib/tools/codelocation.cpp index 542408795..ebfd5edc6 100644 --- a/src/lib/corelib/tools/codelocation.cpp +++ b/src/lib/corelib/tools/codelocation.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -118,9 +118,9 @@ QString CodeLocation::toString() const if (isValid()) { str = QDir::toNativeSeparators(filePath()); QString lineAndColumn; - if (line() > 0 && !str.contains(QRegExp(QStringLiteral(":[0-9]+$")))) + if (line() > 0 && !str.contains(QRegularExpression(QStringLiteral(":[0-9]+$")))) lineAndColumn += QLatin1Char(':') + QString::number(line()); - if (column() > 0 && !str.contains(QRegExp(QStringLiteral(":[0-9]+:[0-9]+$")))) + if (column() > 0 && !str.contains(QRegularExpression(QStringLiteral(":[0-9]+:[0-9]+$")))) lineAndColumn += QLatin1Char(':') + QString::number(column()); str += lineAndColumn; } diff --git a/src/lib/corelib/tools/fileinfo.cpp b/src/lib/corelib/tools/fileinfo.cpp index 8f6b285d4..6fdd90fb1 100644 --- a/src/lib/corelib/tools/fileinfo.cpp +++ b/src/lib/corelib/tools/fileinfo.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #if defined(Q_OS_UNIX) #include @@ -242,17 +242,6 @@ QString FileInfo::resolvePath(const QString &base, const QString &rel, HostOsInf return r; } -bool FileInfo::globMatches(const QRegExp ®exp, const QString &fileName) -{ - const QString pattern = regexp.pattern(); - // May be it's simple wildcard, i.e. "*.cpp"? - if (pattern.startsWith(QLatin1Char('*')) && !isPattern(pattern.midRef(1))) { - // Yes, it's rather simple to just check the extension - return fileName.endsWith(pattern.midRef(1)); - } - return regexp.exactMatch(fileName); -} - #ifdef Q_OS_WIN static QString prependLongPathPrefix(const QString &absolutePath) { diff --git a/src/lib/corelib/tools/fileinfo.h b/src/lib/corelib/tools/fileinfo.h index 9813b69a7..c4ca5931a 100644 --- a/src/lib/corelib/tools/fileinfo.h +++ b/src/lib/corelib/tools/fileinfo.h @@ -79,7 +79,6 @@ public: static bool isPattern(const QString &str); static QString resolvePath(const QString &base, const QString &rel, HostOsInfo::HostOs hostOs = HostOsInfo::hostOs()); - static bool globMatches(const QRegExp &pattern, const QString &subject); static bool isFileCaseCorrect(const QString &filePath); // Symlink-correct check. diff --git a/src/lib/corelib/tools/jsliterals.cpp b/src/lib/corelib/tools/jsliterals.cpp index 74328006c..69d170336 100644 --- a/src/lib/corelib/tools/jsliterals.cpp +++ b/src/lib/corelib/tools/jsliterals.cpp @@ -41,7 +41,7 @@ #include -#include +#include namespace qbs { @@ -53,7 +53,7 @@ QString toJSLiteral(const bool b) QString toJSLiteral(const QString &str) { QString js = str; - js.replace(QRegExp(QLatin1String("([\\\\\"])")), QLatin1String("\\\\1")); + js.replace(QRegularExpression(QLatin1String("([\\\\\"])")), QLatin1String("\\\\1")); js.prepend(QLatin1Char('"')); js.append(QLatin1Char('"')); return js; diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp index 3f2b57e01..18145eafb 100644 --- a/src/lib/corelib/tools/persistence.cpp +++ b/src/lib/corelib/tools/persistence.cpp @@ -48,7 +48,7 @@ namespace qbs { namespace Internal { -static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-128"; +static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-129"; NoBuildGraphError::NoBuildGraphError(const QString &filePath) : ErrorInfo(Tr::tr("Build graph not found for configuration '%1'. Expected location was '%2'.") diff --git a/src/lib/corelib/tools/persistence.h b/src/lib/corelib/tools/persistence.h index e00310321..f97604b42 100644 --- a/src/lib/corelib/tools/persistence.h +++ b/src/lib/corelib/tools/persistence.h @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include @@ -426,10 +426,16 @@ template<> struct PPHelper static void load(QVariant &v, PersistentPool *pool) { v = pool->loadVariant(); } }; -template<> struct PPHelper +template<> struct PPHelper { - static void store(const QRegExp &re, PersistentPool *pool) { pool->store(re.pattern()); } - static void load(QRegExp &re, PersistentPool *pool) { re.setPattern(pool->load()); } + static void store(const QRegularExpression &re, PersistentPool *pool) + { + pool->store(re.pattern()); + } + static void load(QRegularExpression &re, PersistentPool *pool) + { + re.setPattern(pool->load()); + } }; template struct PPHelper> diff --git a/src/lib/corelib/tools/shellutils.cpp b/src/lib/corelib/tools/shellutils.cpp index 33ab2c76c..d032aecac 100644 --- a/src/lib/corelib/tools/shellutils.cpp +++ b/src/lib/corelib/tools/shellutils.cpp @@ -44,7 +44,7 @@ #include "qttools.h" #include -#include +#include #include namespace qbs { @@ -56,7 +56,7 @@ QString shellInterpreter(const QString &filePath) { QTextStream ts(&file); const QString shebang = ts.readLine(); if (shebang.startsWith(QLatin1String("#!"))) { - return (shebang.mid(2).split(QRegExp(QStringLiteral("\\s")), + return (shebang.mid(2).split(QRegularExpression(QStringLiteral("\\s")), QBS_SKIP_EMPTY_PARTS) << QString()).front(); } } @@ -125,9 +125,9 @@ static QString shellQuoteWin(const QString &arg) // The process-level standard quoting allows escaping quotes with backslashes (note // that backslashes don't escape themselves, unless they are followed by a quote). // Consequently, quotes are escaped and their preceding backslashes are doubled. - ret.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\"")); + ret.replace(QRegularExpression(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\"")); // Trailing backslashes must be doubled as well, as they are followed by a quote. - ret.replace(QRegExp(QLatin1String("(\\\\+)$")), QLatin1String("\\1\\1")); + ret.replace(QRegularExpression(QLatin1String("(\\\\+)$")), QLatin1String("\\1\\1")); // However, the shell also interprets the command, and no backslash-escaping exists // there - a quote always toggles the quoting state, but is nonetheless passed down // to the called process verbatim. In the unquoted state, the circumflex escapes diff --git a/src/lib/corelib/tools/version.cpp b/src/lib/corelib/tools/version.cpp index f653256b3..719bc386f 100644 --- a/src/lib/corelib/tools/version.cpp +++ b/src/lib/corelib/tools/version.cpp @@ -39,7 +39,7 @@ #include "version.h" -#include +#include #include namespace qbs { @@ -51,13 +51,14 @@ Version Version::fromString(const QString &versionString, bool buildNumberAllowe pattern += QStringLiteral("(?:\\.(\\d+))?"); // Followed by a dot and a number up to two times. if (buildNumberAllowed) pattern += QStringLiteral("(?:[-.](\\d+))?"); // And possibly a dash or dot followed by the build number. - QRegExp rex(pattern); - if (!rex.exactMatch(versionString)) + const QRegularExpression rex(QRegularExpression::anchoredPattern(pattern)); + const QRegularExpressionMatch match = rex.match(versionString); + if (!match.hasMatch()) return Version{}; - const int majorNr = rex.cap(1).toInt(); - const int minorNr = rex.captureCount() >= 2 ? rex.cap(2).toInt() : 0; - const int patchNr = rex.captureCount() >= 3 ? rex.cap(3).toInt() : 0; - const int buildNr = rex.captureCount() >= 4 ? rex.cap(4).toInt() : 0; + const int majorNr = match.captured(1).toInt(); + const int minorNr = match.lastCapturedIndex() >= 2 ? match.captured(2).toInt() : 0; + const int patchNr = match.lastCapturedIndex() >= 3 ? match.captured(3).toInt() : 0; + const int buildNr = match.lastCapturedIndex() >= 4 ? match.captured(4).toInt() : 0; return Version{majorNr, minorNr, patchNr, buildNr}; } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index b0d9c2976..c6e8b9731 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include @@ -298,7 +298,7 @@ void TestBlackbox::textTemplate() static QStringList sortedFileList(const QByteArray &ba) { - auto list = QString::fromUtf8(ba).split(QRegExp("[\r\n]"), QBS_SKIP_EMPTY_PARTS); + auto list = QString::fromUtf8(ba).split(QRegularExpression("[\r\n]"), QBS_SKIP_EMPTY_PARTS); std::sort(list.begin(), list.end()); return list; } @@ -1072,10 +1072,12 @@ void TestBlackbox::discardUnusedData() QVERIFY2(m_qbsStdout.contains("is Darwin"), m_qbsStdout.constData()); const bool isDarwin = m_qbsStdout.contains("is Darwin: true"); const QString output = QString::fromLocal8Bit(m_qbsStdout); - QRegExp pattern(".*---(.*)---.*"); - QVERIFY2(pattern.exactMatch(output), qPrintable(output)); - QCOMPARE(pattern.captureCount(), 1); - const QString nmPath = pattern.capturedTexts().at(1); + const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"), + QRegularExpression::DotMatchesEverythingOption); + const QRegularExpressionMatch match = pattern.match(output); + QVERIFY2(match.hasMatch(), qPrintable(output)); + QCOMPARE(match.lastCapturedIndex(), 1); + const QString nmPath = match.captured(1); if (!QFile::exists(nmPath)) QSKIP("Cannot check for symbol presence: No nm found."); QProcess nm; @@ -1466,10 +1468,12 @@ void TestBlackbox::versionScript() QCOMPARE(runQbs(QbsRunParameters(QStringList("-q") << ("qbs.installRoot:" + QDir::currentPath()))), 0); const QString output = QString::fromLocal8Bit(m_qbsStderr); - QRegExp pattern(".*---(.*)---.*"); - QVERIFY2(pattern.exactMatch(output), qPrintable(output)); + const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"), + QRegularExpression::DotMatchesEverythingOption); + const QRegularExpressionMatch match = pattern.match(output); + QVERIFY2(match.hasMatch(), qPrintable(output)); QCOMPARE(pattern.captureCount(), 1); - const QString nmPath = pattern.capturedTexts().at(1); + const QString nmPath = match.captured(1); if (!QFile::exists(nmPath)) QSKIP("Cannot check for symbol presence: No nm found."); QProcess nm; @@ -3656,7 +3660,7 @@ void TestBlackbox::erroneousFiles() params.expectFailure = true; QVERIFY(runQbs(params) != 0); QString err = QString::fromLocal8Bit(m_qbsStderr); - if (!err.contains(QRegExp(errorMessage))) { + if (!err.contains(QRegularExpression(errorMessage))) { qDebug().noquote() << "Output: " << err; qDebug().noquote() << "Expected: " << errorMessage; QFAIL("Unexpected error message."); @@ -4932,10 +4936,12 @@ void TestBlackbox::linkerScripts() QCOMPARE(runQbs(runParams), 0); const QString output = QString::fromLocal8Bit(m_qbsStderr); - QRegExp pattern(".*---(.*)---.*"); - QVERIFY2(pattern.exactMatch(output), qPrintable(output)); + const QRegularExpression pattern(QRegularExpression::anchoredPattern(".*---(.*)---.*"), + QRegularExpression::DotMatchesEverythingOption); + const QRegularExpressionMatch match = pattern.match(output); + QVERIFY2(match.hasMatch(), qPrintable(output)); QCOMPARE(pattern.captureCount(), 1); - const QString nmPath = pattern.capturedTexts().at(1); + const QString nmPath = match.captured(1); if (!QFile::exists(nmPath)) QSKIP("Cannot check for symbol presence: No nm found."); @@ -8030,8 +8036,8 @@ void TestBlackbox::badInterpreter() QbsRunParameters params("run"); params.expectFailure = true; - const QRegExp reNoSuchFileOrDir("bad interpreter:.* No such file or directory"); - const QRegExp rePermissionDenied("bad interpreter:.* Permission denied"); + const QRegularExpression reNoSuchFileOrDir("bad interpreter:.* No such file or directory"); + const QRegularExpression rePermissionDenied("bad interpreter:.* Permission denied"); params.arguments = QStringList() << "-p" << "script-interp-missing"; QCOMPARE(runQbs(params), 1); diff --git a/tests/auto/blackbox/tst_clangdb.cpp b/tests/auto/blackbox/tst_clangdb.cpp index 65e562484..c4216ac13 100644 --- a/tests/auto/blackbox/tst_clangdb.cpp +++ b/tests/auto/blackbox/tst_clangdb.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -211,8 +211,10 @@ void TestClangDb::checkClangDetectsSourceCodeProblems() arguments << "-analyze" << "-p" << relativeBuildDir() << sourceFilePath; QVERIFY(runProcess(executable, arguments, stdErr, stdOut) == 0); const QString output = QString::fromLocal8Bit(stdErr); - QVERIFY(output.contains(QRegExp(QStringLiteral("warning.*undefined"), Qt::CaseInsensitive))); - QVERIFY(output.contains(QRegExp(QStringLiteral("warning.*never read"), Qt::CaseInsensitive))); + QVERIFY(output.contains(QRegularExpression(QStringLiteral("warning.*undefined"), + QRegularExpression::CaseInsensitiveOption))); + QVERIFY(output.contains(QRegularExpression(QStringLiteral("warning.*never read"), + QRegularExpression::CaseInsensitiveOption))); } QTEST_MAIN(TestClangDb) diff --git a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp index 15b9ec382..f617d41c7 100644 --- a/tests/auto/cmdlineparser/tst_cmdlineparser.cpp +++ b/tests/auto/cmdlineparser/tst_cmdlineparser.cpp @@ -33,7 +33,6 @@ #include #include -#include #include #include diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index d34069821..78e867fbf 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -955,7 +955,8 @@ void TestLanguage::erroneousFiles() defaultParameters.setProjectFilePath(testProject("/erroneous/") + fileName); loader->loadProject(defaultParameters); } catch (const ErrorInfo &e) { - if (!e.toString().contains(QRegExp(errorMessage))) { + const QRegularExpression reg(errorMessage, QRegularExpression::DotMatchesEverythingOption); + if (!e.toString().contains(reg)) { qDebug() << "Message: " << e.toString(); qDebug() << "Expected: " << errorMessage; QFAIL("Unexpected error message."); -- cgit v1.2.3