diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2022-04-01 17:06:38 +0800 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2022-04-04 09:24:54 +0800 |
commit | 6eaef57cd1fb22ce8070eaf090f4cc111b6f1c95 (patch) | |
tree | 1e3afa20b64f0bdb748892c9649d80684f3de010 | |
parent | ac0c958d58e5be4e625926edc6086e8c06904e14 (diff) |
Ignore warnings in tst_parserstress::ecmascript()
We only care that the parser can parse, and warnings shouldn't affect
that.
Change-Id: I22bab85dbe6cb2f41640adaaa53cb8c85394773b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | tests/auto/qml/parserstress/tst_parserstress.cpp | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/tests/auto/qml/parserstress/tst_parserstress.cpp b/tests/auto/qml/parserstress/tst_parserstress.cpp index 11851de76e..3ae77f688b 100644 --- a/tests/auto/qml/parserstress/tst_parserstress.cpp +++ b/tests/auto/qml/parserstress/tst_parserstress.cpp @@ -40,24 +40,30 @@ public: tst_parserstress() {} private slots: + void init(); void ecmascript_data(); void ecmascript(); private: - static QStringList findJSFiles(const QDir &); + static QFileInfoList findJSFiles(const QDir &); QQmlEngine engine; }; -QStringList tst_parserstress::findJSFiles(const QDir &d) +void tst_parserstress::init() { - QStringList rv; + QTest::failOnWarning(QRegularExpression(QStringLiteral(".?"))); +} + +QFileInfoList tst_parserstress::findJSFiles(const QDir &d) +{ + QFileInfoList rv; - QStringList files = d.entryList(QStringList() << QLatin1String("*.js"), + const QFileInfoList files = d.entryInfoList(QStringList() << QLatin1String("*.js"), QDir::Files); - foreach (const QString &file, files) { - if (file == "browser.js") + for (const QFileInfo &fileInfo : files) { + if (fileInfo.fileName() == "browser.js") continue; - rv << d.absoluteFilePath(file); + rv << fileInfo; } QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | @@ -71,24 +77,45 @@ QStringList tst_parserstress::findJSFiles(const QDir &d) return rv; } +struct IgnoredWarning { + QString ignorePattern; + int timesToIgnore; +}; + void tst_parserstress::ecmascript_data() { QString testDataDir = QFileInfo(QFINDTESTDATA("tests/shell.js")).absolutePath(); QVERIFY2(!testDataDir.isEmpty(), qPrintable("Cannot find testDataDir!")); QDir dir(testDataDir); - QStringList files = findJSFiles(dir); - - QTest::addColumn<QString>("file"); - foreach (const QString &file, files) - QTest::newRow(qPrintable(file)) << file; + const QFileInfoList files = findJSFiles(dir); + + // We only care that the parser can parse, and warnings shouldn't affect that. + QHash<QString, IgnoredWarning> warningsToIgnore = { + { "15.1.2.2-1.js", { "Variable \"POWER\" is used before its declaration at .*", 48 } }, + { "15.1.2.4.js", { "Variable \"index\" is used before its declaration at .*", 6 } }, + { "15.1.2.5-1.js", { "Variable \"index\" is used before its declaration at .*", 6 } }, + { "15.1.2.5-2.js", { "Variable \"index\" is used before its declaration at .*", 6 } }, + { "15.1.2.5-3.js", { "Variable \"index\" is used before its declaration at .*", 6 } }, + { "12.6.3-4.js", { "Variable \"value\" is used before its declaration at .*", 4 } }, + { "try-006.js", { "Variable \"EXCEPTION_STRING\" is used before its declaration at .*", 2 } }, + { "try-007.js", { "Variable \"EXCEPTION_STRING\" is used before its declaration at .*", 2 } }, + { "try-008.js", { "Variable \"INVALID_INTEGER_VALUE\" is used before its declaration at .*", 2 } }, + { "regress-94506.js", { "Variable \"arguments\" is used before its declaration at .*", 2 } }, + }; + + QTest::addColumn<QFileInfo>("fileInfo"); + QTest::addColumn<IgnoredWarning>("warningToIgnore"); + for (const QFileInfo &fileInfo : files) + QTest::newRow(qPrintable(fileInfo.absoluteFilePath())) << fileInfo << warningsToIgnore.value(fileInfo.fileName()); } void tst_parserstress::ecmascript() { - QFETCH(QString, file); + QFETCH(QFileInfo, fileInfo); + QFETCH(IgnoredWarning, warningToIgnore); - QFile f(file); + QFile f(fileInfo.absoluteFilePath()); QVERIFY(f.open(QIODevice::ReadOnly)); QByteArray data = f.readAll(); @@ -112,13 +139,16 @@ void tst_parserstress::ecmascript() QByteArray qmlData = qml.toUtf8(); + if (!warningToIgnore.ignorePattern.isEmpty()) { + for (int i = 0; i < warningToIgnore.timesToIgnore; ++i) + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(warningToIgnore.ignorePattern)); + } + QQmlComponent component(&engine); component.setData(qmlData, QUrl()); - QFileInfo info(file); - - if (info.fileName() == QLatin1String("regress-352044-02-n.js")) { + if (fileInfo.fileName() == QLatin1String("regress-352044-02-n.js")) { QVERIFY(component.isError()); QCOMPARE(component.errors().length(), 2); |