mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 518699: cleanup platform breakpoints between tests
Ensure no platform breakpoints are left over from previous tests Change-Id: I3266636e9014d4930ec72f7411c9a4dc737d0d9f
This commit is contained in:
parent
195ae12776
commit
41b5a72c73
3 changed files with 47 additions and 11 deletions
|
@ -54,11 +54,13 @@ import org.eclipse.core.runtime.Platform;
|
|||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IBreakpointManager;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.core.model.IBreakpoint;
|
||||
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -289,6 +291,16 @@ public class BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure we are starting with a clean/known state. That means no
|
||||
* platform breakpoints that will be automatically installed.
|
||||
*/
|
||||
public void removeAllPlatformBreakpoints() throws CoreException {
|
||||
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
|
||||
IBreakpoint[] breakpoints = manager.getBreakpoints();
|
||||
manager.removeBreakpoints(breakpoints, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure we are starting with a clean/known state. That means no
|
||||
* existing launches.
|
||||
|
@ -327,6 +339,7 @@ public class BaseTestCase {
|
|||
@Before
|
||||
public void doBeforeTest() throws Exception {
|
||||
removeTeminatedLaunchesBeforeTest();
|
||||
removeAllPlatformBreakpoints();
|
||||
setLaunchAttributes();
|
||||
doLaunch();
|
||||
}
|
||||
|
@ -591,6 +604,7 @@ public class BaseTestCase {
|
|||
assertLaunchTerminates();
|
||||
fLaunch = null;
|
||||
}
|
||||
removeAllPlatformBreakpoints();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -226,10 +226,8 @@ public class SourceLookupTest extends BaseParametrizedTestCase {
|
|||
public void doAfterTest() throws Exception {
|
||||
super.doAfterTest();
|
||||
|
||||
removeAllPlatformBreakpoints();
|
||||
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
|
||||
IBreakpoint[] breakpoints = manager.getBreakpoints();
|
||||
manager.removeBreakpoints(breakpoints, true);
|
||||
|
||||
manager.removeBreakpointListener(fBreakpointListener);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
|
|||
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseParametrizedTestCase;
|
||||
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
|
||||
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IBreakpointManager;
|
||||
|
@ -81,6 +82,7 @@ public class TraceFileTest extends BaseParametrizedTestCase {
|
|||
private IGDBTraceControl fTraceService;
|
||||
private IBreakpointsTargetDMContext fBreakpointsDmc;
|
||||
private ITraceTargetDMContext fTraceTargetDmc;
|
||||
private boolean suppressRemoveAllPlatformBreakpoints;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -102,6 +104,18 @@ public class TraceFileTest extends BaseParametrizedTestCase {
|
|||
System.out.println("ERROR: Failed to delete all breakpoints");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Some tests call doBefore/After in the middle of their test and rely on
|
||||
* platform breakpoints to survive that step. So override with the ability
|
||||
* to disable.
|
||||
*/
|
||||
@Override
|
||||
public void removeAllPlatformBreakpoints() throws CoreException {
|
||||
if (!suppressRemoveAllPlatformBreakpoints) {
|
||||
super.removeAllPlatformBreakpoints();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
|
@ -176,10 +190,15 @@ public class TraceFileTest extends BaseParametrizedTestCase {
|
|||
|
||||
try {
|
||||
createTraceFile();
|
||||
// Cleanup the interim launch that we just caused
|
||||
doAfterTest();
|
||||
// Setup for the upcoming launch
|
||||
doBeforeTest();
|
||||
suppressRemoveAllPlatformBreakpoints = true;
|
||||
try {
|
||||
// Cleanup the interim launch that we just caused
|
||||
doAfterTest();
|
||||
// Setup for the upcoming launch
|
||||
doBeforeTest();
|
||||
} finally {
|
||||
suppressRemoveAllPlatformBreakpoints = false;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// If we cannot create the trace file, ignore the test using the
|
||||
// assume check below. The reason for the failure could be a missing
|
||||
|
@ -214,10 +233,15 @@ public class TraceFileTest extends BaseParametrizedTestCase {
|
|||
// the required test ourselves.
|
||||
try {
|
||||
testTraceFile();
|
||||
// Cleanup the interim launch that we just caused
|
||||
doAfterTest();
|
||||
// Setup for the upcoming launch
|
||||
doBeforeTest();
|
||||
suppressRemoveAllPlatformBreakpoints = true;
|
||||
try {
|
||||
// Cleanup the interim launch that we just caused
|
||||
doAfterTest();
|
||||
// Setup for the upcoming launch
|
||||
doBeforeTest();
|
||||
} finally {
|
||||
suppressRemoveAllPlatformBreakpoints = false;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// If we cannot setup properly, ignore the test using the
|
||||
// assume check below. The reason for the failure could be a missing
|
||||
|
|
Loading…
Add table
Reference in a new issue