diff --git a/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc b/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc index f05c16181a6..5fa0f05c1a1 100644 --- a/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc +++ b/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc @@ -359,10 +359,6 @@ found by the code based test frameworks and are registered as test with the build system. - If a test takes more than a minute to execute, the default timeout might - stop the test execution. To increase the timeout, go to \preferences > - \uicontrol {Testing} > \uicontrol General. - \section1 Select tests to run The \uicontrol Tests view shows all the tests found for the currently active @@ -501,7 +497,7 @@ the current project. \row \li \uicontrol {Timeout} - \li The maximum time in seconds to execute a test case. + \li Set a maximum time in seconds to execute a test case. \row \li \uicontrol {Reset Cached Choices} \li Sometimes, \QC cannot deduce which executable or run configuration to diff --git a/src/plugins/autotest/ctest/ctesttreeitem.cpp b/src/plugins/autotest/ctest/ctesttreeitem.cpp index ad744bb5c87..a9f68d6895a 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.cpp +++ b/src/plugins/autotest/ctest/ctesttreeitem.cpp @@ -87,7 +87,11 @@ QList CTestTreeItem::testConfigurationsFor(const QStringLi return {}; const ProjectExplorer::BuildSystem *buildSystem = target->buildSystem(); - QStringList options{"--timeout", QString::number(testSettings().timeout() / 1000)}; + QStringList options; + if (testSettings().useTimeout()) { + options << "--timeout" + << QString::number(testSettings().timeout() / 1000); + } options << theCTestTool().activeSettingsAsOptions(); CommandLine command = buildSystem->commandLineForTests(selected, options); if (command.executable().isEmpty()) diff --git a/src/plugins/autotest/qtest/qttest_utils.cpp b/src/plugins/autotest/qtest/qttest_utils.cpp index 3717a563862..c052e583fda 100644 --- a/src/plugins/autotest/qtest/qttest_utils.cpp +++ b/src/plugins/autotest/qtest/qttest_utils.cpp @@ -137,9 +137,11 @@ Environment prepareBasicEnvironment(const Environment &env) result.set("QT_FORCE_STDERR_LOGGING", "1"); result.set("QT_LOGGING_TO_CONSOLE", "1"); } - const int timeout = testSettings().timeout(); - if (timeout > 5 * 60 * 1000) // Qt5.5 introduced hard limit, Qt5.6.1 added env var to raise this - result.set("QTEST_FUNCTION_TIMEOUT", QString::number(timeout)); + if (testSettings().useTimeout()) { + const int timeout = testSettings().timeout(); + if (timeout > 5 * 60 * 1000) // Qt5.5 introduced hard limit, Qt5.6.1 added env var to raise this + result.set("QTEST_FUNCTION_TIMEOUT", QString::number(timeout)); + } return result; } diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 7dbbb49cdca..fe3fe22fdd9 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -412,8 +412,10 @@ void TestRunner::runTestsHelper() } process.setEnvironment(environment); - m_cancelTimer.setInterval(testSettings().timeout()); - m_cancelTimer.start(); + if (testSettings().useTimeout()) { + m_cancelTimer.setInterval(testSettings().timeout()); + m_cancelTimer.start(); + } qCInfo(runnerLog) << "Command:" << process.commandLine().executable(); qCInfo(runnerLog) << "Arguments:" << process.commandLine().arguments(); diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp index 174773b757c..42407ab9034 100644 --- a/src/plugins/autotest/testsettings.cpp +++ b/src/plugins/autotest/testsettings.cpp @@ -33,13 +33,19 @@ TestSettings::TestSettings() scanThreadLimit.setSpecialValueText("Automatic"); scanThreadLimit.setToolTip(Tr::tr("Number of worker threads used when scanning for tests.")); + useTimeout.setSettingsKey("UseTimeout"); + useTimeout.setDefaultValue(false); + useTimeout.setLabelText(Tr::tr("Timeout")); + useTimeout.setToolTip(Tr::tr("Use a timeout while executing test cases.")); + timeout.setSettingsKey("Timeout"); timeout.setDefaultValue(defaultTimeout); timeout.setRange(5000, 36'000'000); // 36 Mio ms = 36'000 s = 10 h timeout.setSuffix(Tr::tr(" s")); // we show seconds, but store milliseconds timeout.setDisplayScaleFactor(1000); timeout.setToolTip(Tr::tr("Timeout used when executing test cases. This will apply " - "for each test case on its own, not the whole project.")); + "for each test case on its own, not the whole project. " + "Overrides test framework or build system defaults.")); omitInternalMsg.setSettingsKey("OmitInternal"); omitInternalMsg.setDefaultValue(true); @@ -106,6 +112,7 @@ TestSettings::TestSettings() fromSettings(); + timeout.setEnabler(&useTimeout); resultDescriptionMaxSize.setEnabler(&limitResultDescription); popupOnFail.setEnabler(&popupOnFinish); } diff --git a/src/plugins/autotest/testsettings.h b/src/plugins/autotest/testsettings.h index d73f3d3454b..50df720462a 100644 --- a/src/plugins/autotest/testsettings.h +++ b/src/plugins/autotest/testsettings.h @@ -31,6 +31,7 @@ public: void fromSettings(); Utils::IntegerAspect scanThreadLimit{this}; + Utils::BoolAspect useTimeout{this}; Utils::IntegerAspect timeout{this}; Utils::BoolAspect omitInternalMsg{this}; Utils::BoolAspect omitRunConfigWarn{this}; diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index 4bde0e98cb4..f74716b8e20 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -50,8 +50,6 @@ private: TestSettingsWidget::TestSettingsWidget() { - auto timeoutLabel = new QLabel(Tr::tr("Timeout:")); - timeoutLabel->setToolTip(Tr::tr("Timeout used when executing each test case.")); auto scanThreadLabel = new QLabel(Tr::tr("Scan threads:")); scanThreadLabel->setToolTip("Number of worker threads used when scanning for tests."); @@ -98,7 +96,7 @@ TestSettingsWidget::TestSettingsWidget() s.displayApplication, s.processArgs, Row { Tr::tr("Automatically run"), s.runAfterBuild, st }, - Row { timeoutLabel, s.timeout, st }, + Row { s.useTimeout, s.timeout, st }, Row { resetChoicesButton, st } } };