forked from qt-creator/qt-creator
QmlJS: Add test for recursive declared items
Tweak the test to allow multiple messages per line. Task-number: QTCREATORBUG-24615 Change-Id: I662ab4801794dc3e49f68667f634337a847bc503 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
6
tests/auto/qml/codemodel/check/SmurfNonRecursive.qml
Normal file
6
tests/auto/qml/codemodel/check/SmurfNonRecursive.qml
Normal file
@@ -0,0 +1,6 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuickControls 2.0 as Controls
|
||||
|
||||
Controls.SmurfNonRecursive {
|
||||
|
||||
}
|
5
tests/auto/qml/codemodel/check/SmurfRecursive.qml
Normal file
5
tests/auto/qml/codemodel/check/SmurfRecursive.qml
Normal file
@@ -0,0 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
SmurfRecursive { // 129 1 14 // 303 1 14
|
||||
|
||||
}
|
@@ -153,12 +153,21 @@ void tst_Check::test()
|
||||
QList<Message> messages = checker();
|
||||
std::sort(messages.begin(), messages.end(), &offsetComparator);
|
||||
|
||||
/*
|
||||
* expected message are marked inside the respective qml file on the line of their occurrence
|
||||
* with a comment stating error number, start column, and end column with optional state to mark
|
||||
* e.g. false positives
|
||||
* if more than 1 message at a line is expected these can be specified by adding further
|
||||
* line comments in the same line
|
||||
*/
|
||||
const QRegularExpression messagePattern(" (-?\\d+) (\\d+) (\\d+)\\s*(# false positive|# wrong warning.*)?");
|
||||
|
||||
QList<Message> expectedMessages;
|
||||
QHash<int, QString> xfails;
|
||||
for (const SourceLocation &comment : doc->engine()->comments()) {
|
||||
const QString text = doc->source().mid(comment.begin(), comment.end() - comment.begin());
|
||||
const QString fullComment = doc->source().mid(comment.begin(), comment.end() - comment.begin());
|
||||
const QStringList splittedComment = fullComment.split("//");
|
||||
for (const QString &text : splittedComment) {
|
||||
const QRegularExpressionMatch match = messagePattern.match(text);
|
||||
if (!match.hasMatch())
|
||||
continue;
|
||||
@@ -178,6 +187,7 @@ void tst_Check::test()
|
||||
if (messagePattern.captureCount() == 4 && !match.captured(4).isEmpty())
|
||||
xfails.insert(expectedMessages.size() - 1, match.captured(4));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < messages.size(); ++i) {
|
||||
if (i >= expectedMessages.size())
|
||||
|
Reference in New Issue
Block a user