mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
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 <marc-andre.laperle@ericsson.com>
This commit is contained in:
parent
9c8bcb28c8
commit
c14f675a8e
2 changed files with 23 additions and 5 deletions
|
@ -16,7 +16,8 @@
|
|||
<packaging>eclipse-test-plugin</packaging>
|
||||
|
||||
<properties>
|
||||
<extra.vmargs></extra.vmargs>
|
||||
<extra.vmargs.indexer.timeout></extra.vmargs.indexer.timeout>
|
||||
<extra.vmargs.displayhelper.timeoutmultipler></extra.vmargs.displayhelper.timeoutmultipler>
|
||||
</properties>
|
||||
|
||||
<!-- Uncommenting this is useful when the repo is built first then you want to run tests on this plugin only -->
|
||||
|
@ -37,7 +38,18 @@
|
|||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<extra.vmargs>-Dindexer.timeout=${indexer.timeout}</extra.vmargs>
|
||||
<extra.vmargs.indexer.timeout>-Dindexer.timeout=${indexer.timeout}</extra.vmargs.indexer.timeout>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>display-timeout-multiplier-set</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>org.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<extra.vmargs.displayhelper.timeoutmultipler>-Dorg.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER=${org.eclipse.cdt.ui.testplugin.DisplayHelper.TIMEOUT_MULTIPLIER}</extra.vmargs.displayhelper.timeoutmultipler>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
@ -50,7 +62,7 @@
|
|||
<version>${tycho-version}</version>
|
||||
<configuration>
|
||||
<useUIHarness>true</useUIHarness>
|
||||
<argLine>${tycho.testArgLine} ${base.ui.test.vmargs} ${extra.vmargs}</argLine>
|
||||
<argLine>${tycho.testArgLine} ${base.ui.test.vmargs} ${extra.vmargs.indexer.timeout} ${extra.vmargs.displayhelper.timeoutmultipler}</argLine>
|
||||
<includes>
|
||||
<include>**/AutomatedSuite.*</include>
|
||||
</includes>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue