diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-06-29 14:22:04 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-06-29 12:37:14 +0000 |
commit | 70c5b3abf439a288219efd147c5c37aeafd6ea3a (patch) | |
tree | 22199ded95359f5d133bcb28c4240f2752dccaf4 | |
parent | 872e4b883d7732c46e1e5d32b60ce698862e5da6 (diff) |
Autotests: Allow to parameterize the "file unlock grace period"
... via the environment. This should help reduce false positives in our
CI.
Change-Id: I28492b4e476289f2d9418a272b167d9a679ebc5f
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r-- | tests/auto/api/tst_api.cpp | 5 | ||||
-rw-r--r-- | tests/auto/shared.h | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 7af87fc32..e07aaf029 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -2202,10 +2202,7 @@ void TestApi::projectDataAfterProductInvalidation() void TestApi::processResult() { - // On Windows, even closed files seem to sometimes block the removal of their parent directories - // for a while. - if (qbs::Internal::HostOsInfo::isWindowsHost()) - QTest::qWait(500); + waitForFileUnlock(); removeBuildDir(defaultSetupParameters("process-result")); QFETCH(int, expectedExitCode); diff --git a/tests/auto/shared.h b/tests/auto/shared.h index b7a3e2b11..6f2552774 100644 --- a/tests/auto/shared.h +++ b/tests/auto/shared.h @@ -65,6 +65,18 @@ inline int testTimeoutInMsecs() return timeoutInSecs * 1000; } +// On Windows, it appears that a lock is sometimes held on files for a short while even after +// they are closed. The likelihood for that seems to increase with the slowness of the machine. +inline void waitForFileUnlock() +{ + bool ok; + int timeoutInSecs = qEnvironmentVariableIntValue("QBS_AUTOTEST_IO_GRACE_PERIOD", &ok); + if (!ok) + timeoutInSecs = qbs::Internal::HostOsInfo::isWindowsHost() ? 1 : 0; + if (timeoutInSecs > 0) + QTest::qWait(timeoutInSecs * 1000); +} + using SettingsPtr = std::unique_ptr<qbs::Settings>; inline SettingsPtr settings() { |