1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 09:55:29 +02:00

Bug 572581: Remove use of Intermittent in testsuite

Instead make the tests non-intermittent. If tests are flaky, they
should be moved to JUnit5 and marked with the flaky tag.

Change-Id: I9c165ec8f16c65383d93d64d17047c0a2597b81c
This commit is contained in:
Jonah Graham 2021-04-09 11:18:18 -04:00
parent 83d4fa001e
commit 6c2fc2d927
4 changed files with 0 additions and 128 deletions

View file

@ -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;
}

View file

@ -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
<code>
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 (){...}
}
</code>
You can also ally this to the whole class
<code>
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();
...
}
</code>
*/
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);
}
}

View file

@ -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";

View file

@ -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;