diff options
author | Markus Duft | 2017-03-10 06:19:29 +0000 |
---|---|---|
committer | Markus Duft | 2017-03-10 06:19:29 +0000 |
commit | 18c3ba29c2e5955385d7d63d876d791c1c4c5190 (patch) | |
tree | 078b53d73f120792e30793cdbbb60d1a527e681c | |
parent | f8b78f2946e2965bc5bcd90c199e3982e844a831 (diff) | |
download | eclipse.platform.debug-18c3ba29c2e5955385d7d63d876d791c1c4c5190.tar.gz eclipse.platform.debug-18c3ba29c2e5955385d7d63d876d791c1c4c5190.tar.xz eclipse.platform.debug-18c3ba29c2e5955385d7d63d876d791c1c4c5190.zip |
Bug 511607 - Improve stability of launch group testsI20170310-2000
Change-Id: Ifa686d72f9629566b53f30ba47dee08c50d74cbe
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
-rw-r--r-- | org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java index 6e1b704d4..ae24f968c 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java @@ -16,6 +16,7 @@ import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.core.runtime.CoreException; @@ -137,7 +138,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { LaunchHistory runHistory = getRunLaunchHistory(); grp.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); - assertTrue("delay was not awaited", (System.currentTimeMillis() - start) > 2000); //$NON-NLS-1$ + assertTrue("delay was not awaited", (System.currentTimeMillis() - start) >= 2000); //$NON-NLS-1$ ILaunchConfiguration[] history = runHistory.getHistory(); assertTrue("history should be size 3", history.length == 3); //$NON-NLS-1$ @@ -180,7 +181,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { LaunchHistory runHistory = getRunLaunchHistory(); grp.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); - assertTrue("returned before termination of Test1", (System.currentTimeMillis() - start) > 2000); //$NON-NLS-1$ + assertTrue("returned before termination of Test1", (System.currentTimeMillis() - start) >= 2000); //$NON-NLS-1$ // is there a way to assert that the group waited for test1 to // terminate? don't think so - at least run the code path to have it @@ -249,6 +250,8 @@ public class LaunchGroupTests extends AbstractLaunchTest { final DummyAttachListener attachListener = new DummyAttachListener(t1); getLaunchManager().addLaunchListener(attachListener); + final AtomicBoolean finished = new AtomicBoolean(); + long start = System.currentTimeMillis(); // start a thread that will produce output on the dummy process after // some time new Thread("Output Producer") { //$NON-NLS-1$ @@ -258,22 +261,22 @@ public class LaunchGroupTests extends AbstractLaunchTest { // wait some time before causing the group to continue Thread.sleep(2000); attachListener.getStream().write("TestOutput"); //$NON-NLS-1$ + finished.set(true); } catch (Exception e) { e.printStackTrace(); } } }.start(); - long start = System.currentTimeMillis(); - // attention: need to do this before launching! LaunchHistory runHistory = getRunLaunchHistory(); - // launching the group should block until the output is produced + // launching the group must block until the output is produced grp.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); getLaunchManager().removeLaunchListener(attachListener); - assertTrue("output was not awaited", (System.currentTimeMillis() - start) > 2000); //$NON-NLS-1$ + assertTrue("thread did not finish", finished.get()); //$NON-NLS-1$ + assertTrue("output was not awaited", (System.currentTimeMillis() - start) >= 2000); //$NON-NLS-1$ ILaunchConfiguration[] history = runHistory.getHistory(); assertTrue("history should be size 3", history.length == 3); //$NON-NLS-1$ |