From 7611ad1c8e85bc4baeb778852850295a1dc9ac22 Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 6 Sep 2018 22:04:15 +0200 Subject: [PATCH] Propose use of SYNCTHING_TEST_TIMEOUT_FACTOR --- connector/tests/connectiontests.cpp | 8 ++++++-- testhelper/helper.h | 3 ++- testhelper/syncthingtestinstance.cpp | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/connector/tests/connectiontests.cpp b/connector/tests/connectiontests.cpp index 8dd7ae1..d2e1b75 100644 --- a/connector/tests/connectiontests.cpp +++ b/connector/tests/connectiontests.cpp @@ -505,7 +505,9 @@ void ConnectionTests::testRequestingLog() timeout.start(); loop.exec(); QObject::disconnect(request); // ensure callback is not called after return (in error case) - CPPUNIT_ASSERT_MESSAGE("log entries returned before timeout", callbackOk); + CPPUNIT_ASSERT_MESSAGE( + argsToString("log entries returned before timeout of ", timeout.interval(), " ms (set SYNCTHING_TEST_TIMEOUT_FACTOR to increase timeout)"), + callbackOk); } void ConnectionTests::testRequestingQrCode() @@ -529,7 +531,9 @@ void ConnectionTests::testRequestingQrCode() timeout.start(); loop.exec(); QObject::disconnect(request); // ensure callback is not called after return (in error case) - CPPUNIT_ASSERT_MESSAGE("QR code returned before timeout", callbackOk); + CPPUNIT_ASSERT_MESSAGE( + argsToString("QR code returned before timeout of ", timeout.interval(), " ms (set SYNCTHING_TEST_TIMEOUT_FACTOR to increase timeout)"), + callbackOk); } void ConnectionTests::testDisconnecting() diff --git a/testhelper/helper.h b/testhelper/helper.h index 68960d4..4e393ae 100644 --- a/testhelper/helper.h +++ b/testhelper/helper.h @@ -367,7 +367,8 @@ bool waitForSignalsOrFail(Action action, int timeout, const SignalInfo &failure, argsToString("Signal(s) ", failedSignalNames(signalInfos...).data(), " has/have not emmitted before ", failure.signalName().data(), '.')); } else if (timeoutFailed) { CPPUNIT_FAIL(argsToString("Signal(s) ", failedSignalNames(signalInfos...).data(), " has/have not emmitted within at least ", timer.interval(), - " ms.", timeoutFactor != 1.0 ? argsToString(" (original timeout: ", timeout, " ms)") : std::string())); + " ms (set environment variable SYNCTHING_TEST_TIMEOUT_FACTOR to increase the timeout).", + timeoutFactor != 1.0 ? argsToString(" (original timeout: ", timeout, " ms)") : std::string())); } #endif return !failureEmitted && !timeoutFailed; diff --git a/testhelper/syncthingtestinstance.cpp b/testhelper/syncthingtestinstance.cpp index 76bb2ab..62cc13d 100644 --- a/testhelper/syncthingtestinstance.cpp +++ b/testhelper/syncthingtestinstance.cpp @@ -36,8 +36,12 @@ void SyncthingTestInstance::start() timeoutFactor = stringToNumber(string(timeoutFactorEnv.data())); cerr << " - Using timeout factor " << timeoutFactor << endl; } catch (const ConversionException &) { - cerr << " - Specified SYNCTHING_TEST_TIMEOUT_FACTOR \"" << timeoutFactorEnv.data() << "\" is no valid double and hence ignored" << endl; + cerr << " - Specified SYNCTHING_TEST_TIMEOUT_FACTOR \"" << timeoutFactorEnv.data() + << "\" is no valid double and hence ignored\n (defaulting to " << timeoutFactor << ')' << endl; } + } else { + cerr << " - No timeout factor set, defaulting to " << timeoutFactor + << ("\n (set environment variable SYNCTHING_TEST_TIMEOUT_FACTOR to specify a factor to run tests on a slow machine)") << endl; } // setup st config