diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/Intermittent.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/Intermittent.java deleted file mode 100644 index 2d4f2bc6244..00000000000 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/Intermittent.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Alena Laskavaia and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Alena Laskavaia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.tests.dsf.gdb.framework; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Target({ METHOD, TYPE }) -@Retention(RUNTIME) -public @interface Intermittent { - int repetition() default 5; -} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/IntermittentRule.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/IntermittentRule.java deleted file mode 100644 index c31e21f84e1..00000000000 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/IntermittentRule.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Alena Laskavaia and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Alena Laskavaia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.tests.dsf.gdb.framework; - -import org.junit.rules.MethodRule; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; - -/** - * This is the rule to add to tests that rarely fail randomly and you want to keep them but cannot figure out they fail. - * It is safe to use it in any class, it will only apply to tests which have @Intermittent annotation - - import org.eclipse.cdt.tests.dsf.gdb.framework.Intermittent - import org.eclipse.cdt.tests.dsf.gdb.framework.IntermittentRule - - class SomeTest { - public @Rule IntermittentRule rule = new IntermittentRule(); - - @Test - @Intermittent(repetition = 3) - public void someTest (){...} - } - - - You can also ally this to the whole class - - import org.eclipse.cdt.tests.dsf.gdb.framework.Intermittent - import org.eclipse.cdt.tests.dsf.gdb.framework.IntermittentRule - - @Intermittent(repetition = 3) - class SomeTest { - public @Rule IntermittentRule rule = new IntermittentRule(); - ... - } - - - */ -public class IntermittentRule implements MethodRule { - public static class RunIntermittent extends Statement { - private final FrameworkMethod method; - private final Statement statement; - - public RunIntermittent(FrameworkMethod method, Statement statement) { - this.method = method; - this.statement = statement; - } - - @Override - public void evaluate() throws Throwable { - int repetition = 1; - Intermittent methodAnnot = method.getAnnotation(Intermittent.class); - if (methodAnnot != null) { - repetition = methodAnnot.repetition(); - } else { - Intermittent classAnnot = method.getDeclaringClass().getAnnotation(Intermittent.class); - if (classAnnot != null) { - repetition = classAnnot.repetition(); - } - } - if (repetition > 1) { - for (int i = 0; i < repetition; i++) { - try { - statement.evaluate(); - break; // did not fail yay, we are done - } catch (Throwable e) { - if (i < repetition - 1) - continue; // try again - throw e; - } - } - } else - statement.evaluate(); - } - } - - @Override - public Statement apply(Statement base, final FrameworkMethod method, final Object target) { - return new RunIntermittent(method, base); - } -} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java index 5708336828e..e56f0905008 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java @@ -55,8 +55,6 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.tests.dsf.gdb.framework.BaseParametrizedTestCase; -import org.eclipse.cdt.tests.dsf.gdb.framework.Intermittent; -import org.eclipse.cdt.tests.dsf.gdb.framework.IntermittentRule; import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; @@ -65,15 +63,12 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.model.IProcess; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @RunWith(Parameterized.class) -@Intermittent(repetition = 3) public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase { - public @Rule IntermittentRule intermittentRule = new IntermittentRule(); protected static final String EXEC_NAME = "LaunchConfigurationAndRestartTestApp.exe"; protected static final String SOURCE_NAME = "LaunchConfigurationAndRestartTestApp.cc"; diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/GDBMultiNonStopRunControlTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/GDBMultiNonStopRunControlTest.java index 8d2f7fab4d5..e5190fea1ce 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/GDBMultiNonStopRunControlTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/GDBMultiNonStopRunControlTest.java @@ -34,15 +34,12 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.tests.dsf.gdb.framework.BaseParametrizedTestCase; -import org.eclipse.cdt.tests.dsf.gdb.framework.Intermittent; -import org.eclipse.cdt.tests.dsf.gdb.framework.IntermittentRule; import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.junit.Assume; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -51,9 +48,7 @@ import org.junit.runners.Parameterized; * Tests IMultiRunControl class for Non-stop multi-threaded application. */ @RunWith(Parameterized.class) -@Intermittent public class GDBMultiNonStopRunControlTest extends BaseParametrizedTestCase { - public @Rule IntermittentRule irule = new IntermittentRule(); private DsfServicesTracker fServicesTracker;