Bug 544133 - Debug Test Suite is unstoppable
Signal end of test runner thread in any case.
Also removed duplicated implementation in ManualSuite.
Change-Id: If5c800895537ec70328ffe546dae0d1069cc95da
Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java
index cd08506..a6f413b 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/DebugSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Paul Pazderski - Bug 544133: signal end of test runner in any case
*******************************************************************************/
package org.eclipse.jdt.debug.tests;
@@ -31,7 +32,6 @@
*/
protected boolean fTesting = true;
-
/**
* Construct the test suite.
*/
@@ -52,18 +52,21 @@
Runnable r = new Runnable() {
@Override
public void run() {
- for (Enumeration<Test> e= tests(); e.hasMoreElements(); ) {
- if (result.shouldStop() ) {
- break;
+ try {
+ for (Enumeration<Test> e= tests(); e.hasMoreElements(); ) {
+ if (result.shouldStop()) {
+ break;
+ }
+ Test test= e.nextElement();
+ runTest(test, result);
}
- Test test= e.nextElement();
- runTest(test, result);
+ } finally {
+ fTesting = false;
+ display.wake();
}
- fTesting = false;
- display.wake();
}
};
- thread = new Thread(r);
+ thread = new Thread(r, "Test Runner");
thread.start();
} catch (Exception e) {
e.printStackTrace();
@@ -79,6 +82,4 @@
}
}
}
-
}
-
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ManualSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ManualSuite.java
index a74b86e..669014d 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ManualSuite.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ManualSuite.java
@@ -13,25 +13,16 @@
*******************************************************************************/
package org.eclipse.jdt.debug.tests;
-import java.util.Enumeration;
-
import org.eclipse.jdt.debug.tests.core.RemoteJavaApplicationTests;
-import org.eclipse.swt.widgets.Display;
import junit.framework.Test;
-import junit.framework.TestResult;
import junit.framework.TestSuite;
/**
* Tests that are to be run manually by the debug team, in addition to
* automated tests.
*/
-public class ManualSuite extends TestSuite {
-
- /**
- * Flag that indicates test are in progress
- */
- protected boolean fTesting = true;
+public class ManualSuite extends DebugSuite {
/**
* Returns the suite. This is required to
@@ -55,48 +46,5 @@
addTest(new TestSuite(RemoteJavaApplicationTests.class));
}
-
- /**
- * Runs the tests and collects their result in a TestResult.
- * The debug tests cannot be run in the UI thread or the event
- * waiter blocks the UI when a resource changes.
- * @see junit.framework.TestSuite#run(junit.framework.TestResult)
- */
- @Override
- public void run(final TestResult result) {
- final Display display = Display.getCurrent();
- Thread thread = null;
- try {
- Runnable r = new Runnable() {
- @Override
- public void run() {
- for (Enumeration<Test> e= tests(); e.hasMoreElements(); ) {
- if (result.shouldStop() ) {
- break;
- }
- Test test= e.nextElement();
- runTest(test, result);
- }
- fTesting = false;
- display.wake();
- }
- };
- thread = new Thread(r);
- thread.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- while (fTesting) {
- try {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
-
}