-
Notifications
You must be signed in to change notification settings - Fork 20
/
GenerateLangRuntime4OfficialExampleMelangeK3FSM_Test.xtend
187 lines (161 loc) · 7.89 KB
/
GenerateLangRuntime4OfficialExampleMelangeK3FSM_Test.xtend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*******************************************************************************
* Copyright (c) 2016, 2017 Inria and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Inria - initial API and implementation
*******************************************************************************/
package org.eclipse.gemoc.studio.tests.system.lwb.feature
import com.google.inject.Inject
import org.eclipse.core.resources.IProject
import org.eclipse.xtext.junit4.AbstractXtextTests
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.XtextRunner
import org.junit.After
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.eclipse.gemoc.xdsmlframework.test.lib.MelangeWorkspaceTestHelper
import org.eclipse.gemoc.xdsmlframework.test.lib.MelangeUiInjectorProvider
import org.eclipse.swt.widgets.Display
import org.junit.BeforeClass
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot
import org.eclipse.gemoc.xdsmlframework.test.lib.WorkspaceTestHelper
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem
import java.util.ArrayList
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil
import org.eclipse.gemoc.xdsmlframework.test.lib.TailWorkspaceLogToStderrRule
import org.junit.Rule
import org.eclipse.gemoc.commons.eclipse.messagingsystem.api.MessagingSystem
import org.junit.rules.TestName
import org.eclipse.gemoc.xdsmlframework.test.lib.GEMOCTestVideoHelper
import org.eclipse.gemoc.commons.eclipse.messagingsystem.api.MessagingSystemManager
/**
* Checks that the provided official sample can compile without error
*/
@RunWith(XtextRunner)
//@RunWith(SWTBotJunit4ClassRunner)
@InjectWith(MelangeUiInjectorProvider)
@FixMethodOrder(MethodSorters::NAME_ASCENDING)
class GenerateLangRuntime4OfficialExampleMelangeK3FSM_Test extends AbstractXtextTests
{
@Inject MelangeWorkspaceTestHelper melangeHelper
static WorkspaceTestHelper helper = new WorkspaceTestHelper
static SWTWorkbenchBot bot;
static MessagingSystem messaggingSystem
@Rule public TestName testName = new TestName();
IProject melangeProject
IProject melangeProject2
static final String BASE_FOLDER_NAME = "tests-inputs-gen/SequentialFSM"
static final String BASE_PROJECT_NAME = "org.eclipse.gemoc.example.melangek3fsm"
static final String PROJECT_NAME = BASE_PROJECT_NAME+".fsm"
static final String MELANGE_FILE = PROJECT_NAME+"/src/org/eclipse/gemoc/example/melangek3fsm/fsm/FSM.melange"
static final String PROJECT_NAME2 = BASE_PROJECT_NAME+".xsfsm"
static final String MELANGE_FILE2 = PROJECT_NAME2+"/src/org/eclipse/gemoc/example/melangek3fsm/xsfsm/language/XSFSM.melange"
@BeforeClass
def static void beforeClass() throws Exception {
GEMOCTestVideoHelper.addTestSuiteVideoLog("starting "+GenerateLangRuntime4OfficialExampleMelangeK3FSM_Test.canonicalName);
helper.waitWorkbench // useful especially for the first test suite that starts the workbench
val MessagingSystemManager msm = new MessagingSystemManager()
messaggingSystem = msm.createBestPlatformMessagingSystem("","");
messaggingSystem.important(System.getProperty("user.dir"),"")
bot = new SWTWorkbenchBot()
SWTBotPreferences.TIMEOUT = WorkspaceTestHelper.SWTBotPreferencesTIMEOUT_4_GEMOC;
bot.resetWorkbench
}
@Rule
public TailWorkspaceLogToStderrRule workspaceLogRule = new TailWorkspaceLogToStderrRule();
@Before
override setUp() {
GEMOCTestVideoHelper.addTestSuiteVideoLog(" - "+testName.methodName);
helper.setTargetPlatform
super.setUp
helper.init
IResourcesSetupUtil::cleanWorkspace
IResourcesSetupUtil::reallyWaitForAutoBuild
// try to respect build order in order to ease compilation, this will speed up the test
helper.deployProject(PROJECT_NAME+".model",BASE_FOLDER_NAME+"/"+PROJECT_NAME+".model.zip")
helper.deployProject(PROJECT_NAME+".k3dsa",BASE_FOLDER_NAME+"/"+PROJECT_NAME+".k3dsa.zip")
melangeProject = helper.deployProject(PROJECT_NAME,BASE_FOLDER_NAME+"/"+PROJECT_NAME+".zip")
//helper.deployProject(PROJECT_NAME+".design",BASE_FOLDER_NAME+"/"+PROJECT_NAME+".design.zip")
//helper.deployProject(PROJECT_NAME+".model.edit",BASE_FOLDER_NAME+"/"+PROJECT_NAME+".model.edit.zip")
//helper.deployProject(PROJECT_NAME+".model.editor",BASE_FOLDER_NAME+"/"+PROJECT_NAME+".model.editor.zip")
melangeProject2 = helper.deployProject(PROJECT_NAME2,BASE_FOLDER_NAME+"/"+PROJECT_NAME2+".zip")
//helper.deployProject(PROJECT_NAME2+".design",BASE_FOLDER_NAME+"/"+PROJECT_NAME2+".design.zip")
IResourcesSetupUtil::reallyWaitForAutoBuild
WorkspaceTestHelper::reallyWaitForJobs(4)
melangeHelper.cleanAll(MELANGE_FILE)
melangeHelper.cleanAll(MELANGE_FILE2)
IResourcesSetupUtil::fullBuild
IResourcesSetupUtil::reallyWaitForAutoBuild
WorkspaceTestHelper::reallyWaitForJobs(4)
val ArrayList<Throwable> thrownException = newArrayList()
Display.^default.syncExec([
try {
melangeHelper.openEditor(MELANGE_FILE)
melangeHelper.openEditor(MELANGE_FILE2)
} catch (Exception e) { thrownException.add(e) }
])
thrownException.forall[e| throw new Exception(e)] // rethrown exception that was executed in the ui thread
}
@After
override tearDown() {
// Nope
}
@Test
def void test01_GenerateAllMelange_usingDirectCommand_NoErrorsInWorkspace() {
val ArrayList<Throwable> thrownException = newArrayList()
Display.^default.syncExec([
try {
melangeHelper.generateAll(MELANGE_FILE)
melangeHelper.generateAll(MELANGE_FILE2)
} catch (Exception e) {
e.printStackTrace
thrownException.add(e)
}
])
thrownException.forall[e| throw new Exception(e)] // rethrown exception that was executed in the ui thread
IResourcesSetupUtil::waitForBuild
IResourcesSetupUtil::reallyWaitForAutoBuild
WorkspaceTestHelper::reallyWaitForJobs(4)
helper.assertNoMarkers
helper.assertProjectExists(PROJECT_NAME)
helper.assertProjectExists(PROJECT_NAME2)
helper.assertProjectExists(PROJECT_NAME2+".xsfsm")
}
@Test
def void test02_GenerateAllMelange_usingClickOnMelangeFile_NoErrorsInWorkspace() {
var projExplorerBot = bot.viewByTitle("Project Explorer").bot
//bot.viewByTitle("Project Explorer").
projExplorerBot.tree().getTreeItem(PROJECT_NAME).expand();
projExplorerBot.tree().getTreeItem(PROJECT_NAME).getNode("src").expand();
projExplorerBot.tree().getTreeItem(PROJECT_NAME).getNode("src").getNode(PROJECT_NAME).expand();
var SWTBotTreeItem melangeFileItem = bot.tree().getTreeItem(PROJECT_NAME).getNode("src").getNode(PROJECT_NAME)
.getNode("FSM.melange").select();
melangeFileItem.contextMenu("Melange").menu("Generate All").click();
// Melange "Generate all is a bit special as it trigger several jobs one after the other
// retry in order to make sure they all have been done
WorkspaceTestHelper::reallyWaitForJobs(50)
IResourcesSetupUtil::reallyWaitForAutoBuild
projExplorerBot = bot.viewByTitle("Project Explorer").bot
//bot.viewByTitle("Project Explorer").
projExplorerBot.tree().getTreeItem(PROJECT_NAME2).expand();
projExplorerBot.tree().getTreeItem(PROJECT_NAME2).getNode("src").expand();
projExplorerBot.tree().getTreeItem(PROJECT_NAME2).getNode("src").getNode(PROJECT_NAME2+".language").expand();
melangeFileItem = bot.tree().getTreeItem(PROJECT_NAME2).getNode("src").getNode(PROJECT_NAME2+".language")
.getNode("XSFSM.melange").select();
melangeFileItem.contextMenu("Melange").menu("Generate All").click();
WorkspaceTestHelper::reallyWaitForJobs(50)
IResourcesSetupUtil::reallyWaitForAutoBuild
helper.assertNoMarkers
helper.assertProjectExists(PROJECT_NAME)
helper.assertProjectExists(PROJECT_NAME2)
helper.assertProjectExists(PROJECT_NAME2+".xsfsm")
}
}