Skip to content

Commit

Permalink
Add new k3fsm modeling samples (#257)
Browse files Browse the repository at this point in the history
* Add new k3fsm modeling projects

* Fix wrong paths in launchers for ThreeStates fsm model

* deploy the new K3FSM model examples using emf.common.ui.examples wizard

contributes to #252

* adapt test to new k3fsm examples folder structure

Signed-off-by: Didier Vojtisek <[email protected]>

Co-authored-by: Didier Vojtisek <[email protected]>
  • Loading branch information
ebousse and dvojtise authored Feb 7, 2022
1 parent 54abcdd commit bcc4faf
Show file tree
Hide file tree
Showing 46 changed files with 8,989 additions and 284 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,27 @@
<!-- K3FSM -->
<mkdir dir="${k3FSM.tests-inputs-gen.path}" />

<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples/" />
<!--K3FSM model example projects -->
<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.Bitshifting.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples.Bitshifting/" />
</zip>
<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.EdgeDetector.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples.EdgeDetector/" />
</zip>
<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.StringtoLowercase.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples.StringtoLowercase/" />
</zip>
<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.StringtoUpperCase.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples.StringtoUpperCase/" />
</zip>
<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.ThreeStates.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples.ThreeStates/" />
</zip>
<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.TrafficLight.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples.TrafficLight/" />
</zip>
<zip destfile="${k3FSM.tests-inputs-gen.path}/org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates.zip">
<fileset dir="${k3FSM.modeling.root}/org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates/" />
</zip>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class DebugOfficialExampleK3FSM_Test extends AbstractXtextTests
static WorkspaceTestHelper helper = new WorkspaceTestHelper

static final String BASE_FOLDER_NAME = "tests-inputs-gen/K3FSM"
static final String BASE_NAME = "org.eclipse.gemoc.example.k3fsm"
static final String MODEL_PROJECT_NAME = BASE_NAME+".model_examples"
static final String MODEL_PROJECT_NAME = "org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates"

static SWTWorkbenchBot bot;

Expand Down Expand Up @@ -153,21 +152,21 @@ class DebugOfficialExampleK3FSM_Test extends AbstractXtextTests
* Stop is done using Engine Status view
*/
@Test
def void test01_TwoStatesUpCast_Model_some_steps_stop_and_clear() throws Exception {
def void test01_TwoStates_Model_some_steps_stop_and_clear() throws Exception {
TwoStatesUpCast_Model_some_steps_stop_and_clear
}

@Test
def void test02_secondRun_TwoStatesUpCast_Model_some_steps_stop_and_clear() throws Exception {
def void test02_secondRun_TwoStates_Model_some_steps_stop_and_clear() throws Exception {
TwoStatesUpCast_Model_some_steps_stop_and_clear
}

private def void TwoStatesUpCast_Model_some_steps_stop_and_clear() {
val runningEnginesRegistry = org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry;

startDebugwoStatesUpCast_Model
startDebugTwoStates_Model
val engine = runningEnginesRegistry.runningEngines.entrySet.get(0).value
assertEquals("GEMOC Kermeta Sequential Engine platform:/resource/org.eclipse.gemoc.example.k3fsm.model_examples/TwoStatesUpcast.k3fsm", engine.name)
assertEquals("GEMOC Kermeta Sequential Engine platform:/resource/"+MODEL_PROJECT_NAME+"/xtext/TwoStates.k3fsm", engine.name)
assertEquals(0,engine.engineStatus.nbLogicalStepRun)
val fsm = engine.executionContext.resourceModel.contents.get(0) as FSM
fsm.currentState.assertNull
Expand Down Expand Up @@ -229,8 +228,8 @@ class DebugOfficialExampleK3FSM_Test extends AbstractXtextTests
*/
@Ignore // this test actually implies to fix https://github.com/eclipse/gemoc-studio-modeldebugging/issues/66
@Test
def void test03_TwoStatesUpCast_Model_run_to_end() throws Exception {
startDebugwoStatesUpCast_Model
def void test03_TwoStates_Model_run_to_end() throws Exception {
startDebugTwoStates_Model

val matcher = allOf(widgetOfType(typeof(ToolItem)),
anyOf(withTooltip("Resu&me (F8)"), withTooltip("Resu&me")),
Expand Down Expand Up @@ -258,28 +257,30 @@ class DebugOfficialExampleK3FSM_Test extends AbstractXtextTests
}

// some reusabe test part
def void startDebugwoStatesUpCast_Model() {
def void startDebugTwoStates_Model() {
val runningEnginesRegistry = org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry;
assertTrue("runningEngineRegistry not empty " +runningEnginesRegistry.runningEngines, runningEnginesRegistry.runningEngines.size == 0)

bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples").select();
bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples").expand();
val item = bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples").waitNode("TwoStatesUpcast.k3fsm").select();
bot.tree().getTreeItem(MODEL_PROJECT_NAME).select();
bot.tree().getTreeItem(MODEL_PROJECT_NAME).expand();
bot.tree().getTreeItem(MODEL_PROJECT_NAME).waitNode("xtext").select();
bot.tree().getTreeItem(MODEL_PROJECT_NAME).getNode("xtext").expand();
val item = bot.tree().getTreeItem(MODEL_PROJECT_NAME).getNode("xtext").waitNode("TwoStates.k3fsm").select();
item.contextMenu("Debug As").menu("Debug Configurations...").click();
bot.tree().getTreeItem("Executable model with GEMOC Java engine").expand();
bot.tree().getTreeItem("Executable model with GEMOC Java engine").waitNode("K3FSM - TwoStatesUpcast(abababa)").select();
bot.tree().getTreeItem("Executable model with GEMOC Java engine").waitNode("K3FSM- TwoStates(abababa)").select();
bot.button("Debug").click();

// accept switch to debug perspective (this also makes sure that the engines has started)
confirmPerspectiveSwitch(bot)

// select stack in Debug view (this opens the xtext editor and enables the F5 buttons)
bot.viewByTitle("Debug").show();
bot.tree().getTreeItem("K3FSM - TwoStatesUpcast(abababa) [Executable model with GEMOC Java engine]").select();
bot.tree().getTreeItem("K3FSM - TwoStatesUpcast(abababa) [Executable model with GEMOC Java engine]").waitNode("Gemoc debug target").waitNode("Model debugging").select();
bot.tree().getTreeItem("K3FSM - TwoStatesUpcast(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").getNode("Model debugging").expand();
bot.tree().getTreeItem("K3FSM - TwoStatesUpcast(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").getNode("Model debugging").waitNode("Engine : TwoStatesUpcast.k3fsm => TwoStateUpcast").select();
bot.tree().getTreeItem("K3FSM - TwoStatesUpcast(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").getNode("Model debugging").waitNode("[FSM] TwoStateUpcast#initializeModel([])").select();
bot.tree().getTreeItem("K3FSM- TwoStates(abababa) [Executable model with GEMOC Java engine]").select();
bot.tree().getTreeItem("K3FSM- TwoStates(abababa) [Executable model with GEMOC Java engine]").waitNode("Gemoc debug target").waitNode("Model debugging").select();
bot.tree().getTreeItem("K3FSM- TwoStates(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").getNode("Model debugging").expand();
bot.tree().getTreeItem("K3FSM- TwoStates(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").getNode("Model debugging").waitNode("Engine : TwoStates.k3fsm => TwoStates").select();
bot.tree().getTreeItem("K3FSM- TwoStates(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").getNode("Model debugging").waitNode("[FSM] TwoStates#initializeModel([])").select();


closeConfigureXtextPopup(bot)
Expand Down Expand Up @@ -307,7 +308,7 @@ class DebugOfficialExampleK3FSM_Test extends AbstractXtextTests
* or timeout exception
*/
def void waitThreadSuspended(){
ModelingWorkbenchTestHelper.waitFirstTargetThreadSuspended("K3FSM - TwoStatesUpcast(abababa)")
ModelingWorkbenchTestHelper.waitFirstTargetThreadSuspended("K3FSM- TwoStates(abababa)")
}

/** simple helper method to get a string representation of the stack*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ class DeployOfficialExampleK3FSM_Test extends AbstractXtextTests
IResourcesSetupUtil::reallyWaitForAutoBuild
WorkspaceTestHelper::reallyWaitForJobs(2)

helper.assertProjectExists(BASE_NAME+".model_examples");
helper.assertProjectExists(BASE_NAME+".model_examples.Bitshifting");
helper.assertProjectExists(BASE_NAME+".model_examples.EdgeDetectors");
helper.assertProjectExists(BASE_NAME+".model_examples.StringtoLowercase");
helper.assertProjectExists(BASE_NAME+".model_examples.StringtoUpperCases");
helper.assertProjectExists(BASE_NAME+".model_examples.ThreeStates");
helper.assertProjectExists(BASE_NAME+".model_examples.TrafficLight");
helper.assertProjectExists(BASE_NAME+".model_examples.TwoStates");

helper.assertNoMarkers();
}
Expand All @@ -154,15 +160,17 @@ class DeployOfficialExampleK3FSM_Test extends AbstractXtextTests
* verifies that we can use the predefined launch configuration and launch a debug session
*/
@Test
def void test02_DebugPredefinedK3Fsm_TwoStatesUpCast_Model_some_steps_and_stop() throws Exception {
def void test02_DebugPredefinedK3Fsm_TwoStates_Model_some_steps_and_stop() throws Exception {
//val activeShell = bot.activeShell // the focus is lost after click on "Browse..."
// open the Debug configuration and start the predefined launch conf
bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples").select();
bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples").expand();
val item = bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples").getNode("TwoStatesUpcast.k3fsm").select();
bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates").select();
bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates").expand();
bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates").getNode("xtext").select();
bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates").getNode("xtext").expand();
val item = bot.tree().getTreeItem("org.eclipse.gemoc.example.k3fsm.model_examples.TwoStates").getNode("xtext").getNode("TwoStates.k3fsm").select();
item.contextMenu("Debug As").menu("Debug Configurations...").click();
bot.tree().getTreeItem("Executable model with GEMOC Java engine").expand();
bot.tree().getTreeItem("Executable model with GEMOC Java engine").getNode("K3FSM - TwoStatesUpcast(abababa)").select();
bot.tree().getTreeItem("Executable model with GEMOC Java engine").getNode("K3FSM- TwoStates(abababa)").select();
bot.button("Debug").click();

// accept switch to debug perspective (this also makes sure that the engines has started)
Expand All @@ -178,12 +186,12 @@ class DeployOfficialExampleK3FSM_Test extends AbstractXtextTests
waitThreadSuspended
clickOnStepInto(bot)
waitThreadSuspended
bot.tree().getTreeItem("K3FSM - TwoStatesUpcast(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").select();
bot.tree().getTreeItem("K3FSM- TwoStates(abababa) [Executable model with GEMOC Java engine]").getNode("Gemoc debug target").select();
bot.toolbarButtonWithTooltip("Resu&me (F8)").click();

closeConfigureXtextPopup(bot)

waitFirstTargetThreadSuspendedOrTerminated("K3FSM - TwoStatesUpcast(abababa)")
waitFirstTargetThreadSuspendedOrTerminated("K3FSM- TwoStates(abababa)")
try {
closeAndClearEngine(bot)
} catch (Exception e){
Expand All @@ -203,7 +211,7 @@ class DeployOfficialExampleK3FSM_Test extends AbstractXtextTests
* or timeout exception
*/
def void waitThreadSuspended(){
waitFirstTargetThreadSuspended("K3FSM - TwoStatesUpcast(abababa)")
waitFirstTargetThreadSuspended("K3FSM- TwoStates(abababa)")
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.gemoc.example.k3fsm.xtext"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ide&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ui&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ui.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ui.tests&quot; type=&quot;4&quot;/&gt;&#10;;&lt;/resources&gt;}"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="org.eclipse.gemoc.example.k3fsm.GenerateK3FSM"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.gemoc.example.k3fsm.xtext"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ide&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ui&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ui.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item path=&quot;/org.eclipse.gemoc.example.k3fsm.xtext.ui.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;/resources&gt;}"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.eclipse.gemoc.example.k3fsm.xtext"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="org.eclipse.gemoc.example.k3fsm.xtext"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="org.eclipse.gemoc.example.k3fsm.GenerateK3FSM"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.gemoc.example.k3fsm.xtext"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Eclipse for K3FSM"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-EclipseXtext_10"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-EclipseXtext_10"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
Expand Down
Loading

0 comments on commit bcc4faf

Please sign in to comment.