aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2021-11-04 09:53:04 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-04 18:32:14 +0000
commit2cdf2a8cb96b5ae6d142d9a498736c79f193b79e (patch)
tree56da41e82cd16420b8f2513b5d7ab209103d58c3
parent6403ba67249a414b026950dde2a903fe11d0c5d3 (diff)
Use the RegExp variant of ignoreWarning() in case line number changes
Using hardcoded line numbers is a source of unrelated test failures (and integration failures). Change-Id: Ie5831c95a13c988339f78e0b4188f72ac1152e56 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 2c34ce97a31c841da53a0a46c4693af83fadd82e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_scrollindicator.qml2
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_stackview.qml35
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml21
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_textarea.qml2
4 files changed, 29 insertions, 31 deletions
diff --git a/tests/auto/quickcontrols2/controls/data/tst_scrollindicator.qml b/tests/auto/quickcontrols2/controls/data/tst_scrollindicator.qml
index 5f6006d40e..363048c0bd 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_scrollindicator.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_scrollindicator.qml
@@ -187,7 +187,7 @@ TestCase {
}
function test_warning() {
- ignoreWarning(Qt.resolvedUrl("tst_scrollindicator.qml") + ":55:1: QML TestCase: ScrollIndicator must be attached to a Flickable")
+ ignoreWarning(/QML TestCase: ScrollIndicator must be attached to a Flickable/)
testCase.ScrollIndicator.vertical = null
}
diff --git a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
index 2716a9f988..72450ebb49 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_stackview.qml
@@ -399,15 +399,15 @@ TestCase {
verify(control)
// missing arguments
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: push: missing arguments")
+ ignoreWarning(/QML StackView: push: missing arguments/)
compare(control.push(), null)
// nothing to push
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: push: nothing to push")
+ ignoreWarning(/QML StackView: push: nothing to push/)
compare(control.push(StackView.Immediate), null)
// unsupported type
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: push: QtObject is not supported. Must be Item or Component.")
+ ignoreWarning(/QML StackView: push: QtObject is not supported. Must be Item or Component./)
control.push(Qt.createQmlObject('import QtQml; QtObject { }', control))
// push(item)
@@ -449,6 +449,13 @@ TestCase {
compare(control.currentItem, item6)
}
+ // Escape special Regexp characters with a '\' (backslash) prefix so that \a str can be
+ // used as a Regexp pattern.
+ function escapeRegExp(str) {
+ // "$&" is the last matched substring
+ return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ }
+
function test_pop() {
var control = createTemporaryObject(stackView, testCase)
verify(control)
@@ -459,7 +466,7 @@ TestCase {
control.push(items, StackView.Immediate)
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: pop: too many arguments")
+ ignoreWarning(/QML StackView: pop: too many arguments/)
compare(control.pop(1, 2, 3), null)
// pop the top most item
@@ -483,7 +490,7 @@ TestCase {
compare(control.currentItem, items[2])
// don't pop non-existent item
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: pop: unknown argument: " + testCase)
+ ignoreWarning(new RegExp(".*QML StackView: pop: unknown argument: " + escapeRegExp(testCase.toString())))
compare(control.pop(testCase, StackView.Immediate), null)
compare(control.depth, 3)
compare(control.currentItem, items[2])
@@ -499,15 +506,15 @@ TestCase {
verify(control)
// missing arguments
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: replace: missing arguments")
+ ignoreWarning(/QML StackView: replace: missing arguments/)
compare(control.replace(), null)
// nothing to push
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: replace: nothing to push")
+ ignoreWarning(/QML StackView: replace: nothing to push/)
compare(control.replace(StackView.Immediate), null)
// unsupported type
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: replace: QtObject is not supported. Must be Item or Component.")
+ ignoreWarning(/QML StackView: replace: QtObject is not supported. Must be Item or Component./)
compare(control.replace(Qt.createQmlObject('import QtQml; QtObject { }', control)), null)
// replace(item)
@@ -1016,20 +1023,18 @@ TestCase {
var control = createTemporaryObject(stackView, testCase, {initialItem: component})
verify(control)
- var error = Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory"
-
ignoreWarning("QQmlComponent: Component is not ready")
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: push: " + error)
+ ignoreWarning(/QML StackView: push: .*non-existent.qml:-1 No such file or directory/)
control.push(Qt.resolvedUrl("non-existent.qml"))
ignoreWarning("QQmlComponent: Component is not ready")
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: replace: " + error)
+ ignoreWarning(/QML StackView: replace: .*non-existent.qml:-1 No such file or directory/)
control.replace(Qt.resolvedUrl("non-existent.qml"))
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: push: invalid url: x://[v]")
+ ignoreWarning(/QML StackView: push: invalid url: x:\/\/\[v\]/)
control.push("x://[v]")
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: replace: invalid url: x://[v]")
+ ignoreWarning(/QML StackView: replace: invalid url: x:\/\/\[v\]/)
control.replace("x://[v]")
control.pop()
@@ -1131,7 +1136,7 @@ TestCase {
compare(control.depth, 1)
// Pushing the same Item should do nothing.
- ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: push: nothing to push")
+ ignoreWarning(/QML StackView: push: nothing to push/)
control.push(item, StackView.Immediate)
compare(control.currentItem, item)
compare(control.depth, 1)
diff --git a/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml b/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml
index 7b4fdcd127..42b23b3614 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_swipedelegate.qml
@@ -216,8 +216,7 @@ TestCase {
var control = createTemporaryObject(swipeDelegateComponent, testCase);
verify(control);
- ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":168:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ignoreWarning(/QML SwipeDelegate: cannot set both behind and left\/right properties/)
control.swipe.behind = itemComponent;
// Shouldn't be any warnings when unsetting delegates.
@@ -225,8 +224,7 @@ TestCase {
compare(control.swipe.leftItem, null);
// right is still set.
- ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":168:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ignoreWarning(/QML SwipeDelegate: cannot set both behind and left\/right properties/)
control.swipe.behind = itemComponent;
control.swipe.right = null;
@@ -234,12 +232,10 @@ TestCase {
control.swipe.behind = itemComponent;
- ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":168:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ignoreWarning(/QML SwipeDelegate: cannot set both behind and left\/right properties/)
control.swipe.left = itemComponent;
- ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":168:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ignoreWarning(/QML SwipeDelegate: cannot set both behind and left\/right properties/)
control.swipe.right = itemComponent;
control.swipe.behind = null;
@@ -253,8 +249,7 @@ TestCase {
var oldLeft = control.swipe.left;
var oldLeftItem = control.swipe.leftItem;
- ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":168:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ignoreWarning(/QML SwipeDelegate: left\/right\/behind properties may only be set when swipe.position is 0/)
control.swipe.left = null;
compare(control.swipe.left, oldLeft);
compare(control.swipe.leftItem, oldLeftItem);
@@ -264,8 +259,7 @@ TestCase {
var oldRight = control.swipe.right;
var oldRightItem = control.swipe.rightItem;
- ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":168:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ignoreWarning(/QML SwipeDelegate: left\/right\/behind properties may only be set when swipe.position is 0/)
control.swipe.right = null;
compare(control.swipe.right, oldRight);
compare(control.swipe.rightItem, oldRightItem);
@@ -290,8 +284,7 @@ TestCase {
var oldBehind = control.swipe.behind;
var oldBehindItem = control.swipe.behindItem;
- ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":168:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ignoreWarning(/QML SwipeDelegate: left\/right\/behind properties may only be set when swipe.position is 0/)
control.swipe.behind = null;
compare(control.swipe.behind, oldBehind);
compare(control.swipe.behindItem, oldBehindItem);
diff --git a/tests/auto/quickcontrols2/controls/data/tst_textarea.qml b/tests/auto/quickcontrols2/controls/data/tst_textarea.qml
index 7f0b52fc10..5fcc4773dc 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_textarea.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_textarea.qml
@@ -352,7 +352,7 @@ TestCase {
}
function test_warning() {
- ignoreWarning(Qt.resolvedUrl("tst_textarea.qml") + ":55:1: QML TestCase: TextArea must be attached to a Flickable")
+ ignoreWarning(/QML TestCase: TextArea must be attached to a Flickable/)
testCase.TextArea.flickable = null
}