aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-07-31 12:06:39 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2017-07-31 10:29:41 +0000
commitbc26762e48732a88cd412430faade77ffc2c8f60 (patch)
treed056baba0c8513ff9491e02d28f61777298fac41 /tests
parent548790931ccac858d9244e4c5546ef1664b0dc4a (diff)
Autotests: Ensure that waitForNewTimestamp() always terminates
Apparently, the abovementioned function has been observed to run seemingly forever in certain environments. Fix that by no longer requiring an actual file timestamp change for it to terminate. Task-number: QBS-1169 Change-Id: I9798309d179b0b6f8857ca8a4a5c1236ca162c27 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/shared.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/auto/shared.h b/tests/auto/shared.h
index 36a15ca74..6a0caaa3c 100644
--- a/tests/auto/shared.h
+++ b/tests/auto/shared.h
@@ -123,14 +123,19 @@ inline void waitForNewTimestamp(const QString &testDir)
if (!f1.open())
qFatal("Failed to open temp file");
const QDateTime initialTime = QFileInfo(f1).lastModified();
- while (true) {
- QTest::qWait(50);
+ int totalMsPassed = 0;
+ while (totalMsPassed <= 2000) {
+ static const int increment = 50;
+ QTest::qWait(increment);
+ totalMsPassed += increment;
QTemporaryFile f2(nameTemplate);
if (!f2.open())
qFatal("Failed to open temp file");
if (QFileInfo(f2).lastModified() > initialTime)
- break;
+ return;
}
+ qWarning("Got no new timestamp after two seconds, going ahead anyway. Subsequent "
+ "test failure might not be genuine.");
}
}