aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-07-20 14:54:03 -0700
committerThiago Macieira <thiago.macieira@intel.com>2018-07-22 01:56:32 +0000
commit0602e657fac200b0fc7d3ae19361ef9ef1247d92 (patch)
treee60496fe7b4475f3498287f6501b4783c243b30e
parent785b12a4d126b8aaac6c378d06a5c885aa5441a7 (diff)
tst_qmldiskcache: speed up test
On some systems, we *do* have sub-second file time resolution, so we don't have to wait one second. Change-Id: Id2be776c7ae0467c9d9ffffd1543325ce53f10fd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index f5905758f3..01f047c323 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -89,7 +89,13 @@ static void waitForFileSystem()
// the newly written file has a modification date newer than an existing cache file, we must
// wait.
// Similar effects of lacking precision have been observed on some Linux systems.
- QThread::sleep(1);
+ static const bool fsHasSubSecondResolution = []() {
+ QDateTime mtime = QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)).lastModified();
+ // 1:1000 chance of a false negative
+ return mtime.toMSecsSinceEpoch() % 1000;
+ }();
+ if (!fsHasSubSecondResolution)
+ QThread::sleep(1);
}
struct TestCompiler