-
Notifications
You must be signed in to change notification settings - Fork 20
/
GenerateTrace4OfficialExampleMelangeK3FSM_Test.xtend
145 lines (120 loc) · 5.87 KB
/
GenerateTrace4OfficialExampleMelangeK3FSM_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
/*******************************************************************************
* 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.eclipse.gemoc.xdsmlframework.test.lib.WorkspaceTestHelper
import java.util.ArrayList
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil
import org.junit.BeforeClass
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot
import org.eclipse.gemoc.xdsmlframework.test.lib.TailWorkspaceLogToStderrRule
import org.junit.Rule
import org.eclipse.gemoc.xdsmlframework.test.lib.GEMOCTestVideoHelper
import org.eclipse.gemoc.commons.eclipse.messagingsystem.api.MessagingSystem
import org.junit.rules.TestName
import org.eclipse.gemoc.commons.eclipse.messagingsystem.api.MessagingSystemManager
/**
* Checks that the provided official sample can compile without error
*/
@RunWith(XtextRunner)
@InjectWith(MelangeUiInjectorProvider)
@FixMethodOrder(MethodSorters::NAME_ASCENDING)
class GenerateTrace4OfficialExampleMelangeK3FSM_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 DSL_FILE = PROJECT_NAME+"/src/org/eclipse/gemoc/example/melangek3fsm/fsm/FSM.dsl"
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"
static final String RUNTIME_PROJECT_NAME2 = PROJECT_NAME2+".xsfsm"
static final String DSL_FILE2 = RUNTIME_PROJECT_NAME2+"/XSFSM.dsl"
@BeforeClass
def static void beforeClass() throws Exception {
GEMOCTestVideoHelper.addTestSuiteVideoLog("starting "+GenerateTrace4OfficialExampleMelangeK3FSM_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"),"")
helper.init
bot = new SWTWorkbenchBot()
SWTBotPreferences.TIMEOUT = WorkspaceTestHelper.SWTBotPreferencesTIMEOUT_4_GEMOC;
bot.resetWorkbench
IResourcesSetupUtil::cleanWorkspace
}
@Rule
public TailWorkspaceLogToStderrRule workspaceLogRule = new TailWorkspaceLogToStderrRule();
@Before
override setUp() {
GEMOCTestVideoHelper.addTestSuiteVideoLog(" - "+testName.methodName);
helper.setTargetPlatform
super.setUp
helper.init
IResourcesSetupUtil::cleanWorkspace
// 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")
melangeProject2 = helper.deployProject(PROJECT_NAME2+".xsfsm",BASE_FOLDER_NAME+"/"+PROJECT_NAME2+".xsfsm.zip")
//helper.deployProject(PROJECT_NAME2+".design",BASE_FOLDER_NAME+"/"+PROJECT_NAME2+".design.zip")
IResourcesSetupUtil::reallyWaitForAutoBuild
IResourcesSetupUtil::fullBuild
IResourcesSetupUtil::reallyWaitForAutoBuild
WorkspaceTestHelper::reallyWaitForJobs(4)
}
@After
override tearDown() {
// Nope
}
@Test
def void test01GenerateTrace_usingDirectCommand_NoErrorsInWorkspace() {
val ArrayList<Throwable> thrownException = newArrayList()
Display.^default.syncExec([
try{
melangeHelper.generateTrace(DSL_FILE2, "XSFSM", RUNTIME_PROJECT_NAME2+".trace")
} catch (Exception e) {
thrownException.add(e)
}
])
thrownException.forall[e| throw new Exception(e)] // rethrown exception that was executed in the ui thread
IResourcesSetupUtil::fullBuild
WorkspaceTestHelper::reallyWaitForJobs(50)
IResourcesSetupUtil::reallyWaitForAutoBuild
helper.assertNoMarkers
helper.assertProjectExists(RUNTIME_PROJECT_NAME2+".trace")
}
}