From c14f675a8e99aa3e50149da5560bf849944407d9 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Tue, 30 Aug 2016 15:04:06 -0400 Subject: [PATCH] Add a timeout multipler for DisplayHelper DisplayHelper is used to run the event loop until a condition is met or until a maximum timeout is reached. This timeout varies between hundreds of milliseconds to a few seconds. When the tests are running on a machine that is known to be quite under load (Hudson), the timeouts in the milliseconds are too optimistics as there can be a lot of other things running at the same time on the machine. This change adds a multipler (default 1) that can be controlled from the maven command line, for example: -Dorg.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER=5 Change-Id: I9c1517ac2641768e8ae0f4508bf9a008931ef805 Signed-off-by: Marc-Andre Laperle --- core/org.eclipse.cdt.ui.tests/pom.xml | 18 +++++++++++++++--- .../cdt/ui/testplugin/DisplayHelper.java | 10 ++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/pom.xml b/core/org.eclipse.cdt.ui.tests/pom.xml index cf8f7d2f13e..1776624bce1 100644 --- a/core/org.eclipse.cdt.ui.tests/pom.xml +++ b/core/org.eclipse.cdt.ui.tests/pom.xml @@ -16,7 +16,8 @@ eclipse-test-plugin - + + @@ -37,7 +38,18 @@ - -Dindexer.timeout=${indexer.timeout} + -Dindexer.timeout=${indexer.timeout} + + + + display-timeout-multiplier-set + + + org.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER + + + + -Dorg.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER=${org.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER} @@ -50,7 +62,7 @@ ${tycho-version} true - ${tycho.testArgLine} ${base.ui.test.vmargs} ${extra.vmargs} + ${tycho.testArgLine} ${base.ui.test.vmargs} ${extra.vmargs.indexer.timeout} ${extra.vmargs.displayhelper.timeoutmultipler} **/AutomatedSuite.* diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/DisplayHelper.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/DisplayHelper.java index f3269660766..04e5373e56f 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/DisplayHelper.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/DisplayHelper.java @@ -33,6 +33,12 @@ import org.eclipse.swt.widgets.Display; * @since 4.0 */ public abstract class DisplayHelper { + private static final long TIMEOUT_MULTIPLIER; + static + { + TIMEOUT_MULTIPLIER = Integer.parseInt(System.getProperty("org.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER", "1")); + } + /** * Creates a new instance. */ @@ -74,7 +80,7 @@ public abstract class DisplayHelper { // repeatedly sleep until condition becomes true or timeout elapses DisplayWaiter waiter= new DisplayWaiter(display); - DisplayWaiter.Timeout timeoutState= waiter.start(timeout); + DisplayWaiter.Timeout timeoutState= waiter.start(timeout * TIMEOUT_MULTIPLIER); boolean condition; try { do { @@ -210,7 +216,7 @@ public abstract class DisplayHelper { // repeatedly sleep until condition becomes true or timeout elapses DisplayWaiter waiter= new DisplayWaiter(display, true); long currentTimeMillis= System.currentTimeMillis(); - long finalTimeout= timeout + currentTimeMillis; + long finalTimeout= timeout * TIMEOUT_MULTIPLIER + currentTimeMillis; if (finalTimeout < currentTimeMillis) finalTimeout= Long.MAX_VALUE; boolean condition;