Skip to content

Commit 62b99fd

Browse files
authored
Disable flacky tests (#192)
* add helper to analyze SWTBot context * improved report of swt status in case of failure * prevent race condition in updating sirius representations * change Sirius notification refresh stategy to command queue this prevent multiple simultaneous call to refresh sirius representation. however, everything is refreshed at last thanks to the queue * use swtbot UIThreadRunnable instead of Display.syncExec contribute to eclipse-gemoc/gemoc-studio#123 Signed-off-by: Didier Vojtisek <[email protected]>
1 parent 7f4fd20 commit 62b99fd

File tree

3 files changed

+86
-4
lines changed

3 files changed

+86
-4
lines changed

framework/execution_framework/plugins/org.eclipse.gemoc.executionframework.extensions.sirius/src/org/eclipse/gemoc/executionframework/extensions/sirius/services/AbstractGemocDebuggerServices.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.eclipse.sirius.ui.business.api.session.SessionUIManager;
5757
import org.eclipse.sirius.viewpoint.DRepresentation;
5858
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
59+
import org.eclipse.swt.widgets.Display;
5960

6061

6162
/*
@@ -628,6 +629,14 @@ public void setCurrentFrame(String debugModelID, StackFrame frame) {
628629
currentFrame = frame;
629630
Set<URI> instructionUris = CURRENT_INSTRUCTIONS_PER_FRAME.get(getCurrentFrame());
630631
if (instructionUris != null) {
632+
// use async exec even if already run in UI Thread in order to prevent possible
633+
// race conditions on sirius refresh
634+
Display.getDefault().asyncExec(new Runnable() {
635+
@Override
636+
public void run() {
637+
notifySirius(instructionUris, debugModelID);
638+
}
639+
});
631640
notifySirius(instructionUris, debugModelID);
632641
}
633642
}

framework/execution_framework/plugins/org.eclipse.gemoc.executionframework.extensions.sirius/src/org/eclipse/gemoc/executionframework/extensions/sirius/ui/preferences/PreferenceInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
2727
public void initializeDefaultPreferences() {
2828
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
2929

30-
store.setDefault(PreferenceConstants.P_REFRESH_STRATEGY, AnimationRefreshStrategy.Every.toString());
30+
store.setDefault(PreferenceConstants.P_REFRESH_STRATEGY, AnimationRefreshStrategy.CommandQueue.toString());
3131
store.setDefault(PreferenceConstants.P_REFRESH_FREQUENCY_LIMIT, 500);
3232

3333
}

framework/xdsml_framework/tests/org.eclipse.gemoc.xdsmlframework.test.lib/src/org/eclipse/gemoc/xdsmlframework/test/lib/SWTBotHelper.xtend

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ package org.eclipse.gemoc.xdsmlframework.test.lib
1212

1313
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot
1414

15+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf
16+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.anyOf
17+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType
18+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle
19+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withTooltip
20+
import org.eclipse.swt.widgets.Button
21+
import org.eclipse.swt.widgets.ToolItem
22+
import org.eclipse.swt.widgets.Widget
23+
import java.util.List
24+
import org.eclipse.swt.widgets.Display
25+
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable
26+
import org.eclipse.swtbot.swt.finder.results.VoidResult
27+
1528
/**
1629
* Class containing helper methods for testing a workspace in a GEMOC Language workbench
1730
*/
@@ -23,9 +36,69 @@ class SWTBotHelper {
2336
* also wait for idle time to triggers new jobs
2437
*/
2538
static def void printShellList(SWTWorkbenchBot bot) {
26-
println("SWTBOT Known shells :")
27-
for (shell : bot.shells) {
28-
println("\t"+shell.text)
39+
val shells = bot.shells.toList
40+
println("SWTBot Known shells("+shells.size+"):")
41+
for (shell : shells) {
42+
println("\t"+shell)
43+
}
44+
}
45+
46+
static def void printTreeList(SWTWorkbenchBot bot) {
47+
println("SWTBot tree(" + bot.tree().allItems.size + "):")
48+
for (item : bot.tree().allItems) {
49+
println("\t" + item)
50+
}
51+
}
52+
53+
static def void printViewList(SWTWorkbenchBot bot) {
54+
val views = bot.views
55+
println("SWTBot View(" + views.size + "):")
56+
for (item : views) {
57+
UIThreadRunnable.syncExec(new VoidResult() {
58+
override run() {
59+
println("\t" + item.title+ " "+ item.widget)
60+
printWidgetList("\t\t","View ToolBarButton", item.toolbarButtons.map[swtBut | swtBut.widget].toList)
61+
}
62+
})
63+
}
64+
}
65+
66+
static def printSWTBotStatus(SWTWorkbenchBot bot) {
67+
println("### SWTBot context analysis ###")
68+
printShellList(bot)
69+
printViewList(bot)
70+
printTreeList(bot)
71+
72+
UIThreadRunnable.syncExec(new VoidResult() {
73+
override run() {
74+
try {
75+
val matcherButton = allOf(widgetOfType(typeof(Button) /*, withLabel(label), withStyle(SWT.PUSH, "SWT.PUSH")*/ ))
76+
val buttons = bot.widgets(matcherButton).toList
77+
printWidgetList("", "Button",buttons)
78+
} catch (Exception e) {
79+
println("SWTBot Button(0) [no Button in the UI after 20000ms]")
80+
// this has required a 20000ms timeout but there is no Button in the bot now
81+
}
82+
val matcherToolItem = allOf(
83+
widgetOfType(typeof(ToolItem))
84+
// , anyOf(withTooltip("Step &Into (F5)"), withTooltip("Step &Into")), withStyle(SWT.PUSH, "SWT.PUSH")
85+
)
86+
val toolItems = bot.widgets(matcherToolItem).toList
87+
printWidgetList("","ToolItem", toolItems)
88+
}
89+
})
90+
}
91+
92+
static def printWidgetList(String indent, String itemType, List<? extends Widget> items) {
93+
println(indent +"SWTBot " + itemType + "(" + items.size + "):")
94+
for (item : items) {
95+
if(item instanceof ToolItem) {
96+
println(indent +"\t"+ item + " toolTipText="+item.toolTipText)
97+
} else if(item instanceof Button) {
98+
println(indent +"\t" + item + " text="+ item.text + " toolTipText="+item.toolTipText)
99+
} else {
100+
println(indent +"\t" + item)
101+
}
29102
}
30103
}
31104

0 commit comments

Comments
 (0)