Skip to content

Commit

Permalink
Tests for issue #78.
Browse files Browse the repository at this point in the history
* Made test order fixed in JUnit to exhibit problem with issue #78.
* Because there are side-effects from the order in which tests run, I've
made the order fixed. For running from within Eclipse this is fine, but
Maven required tweaking the config for tycho-surefire-plugin.
* It seems because the new test runner uses the Eclipse RCP there is no
need to manually load the RoboChart libraries from the class loader.
Again, this helps to show the problem for the new test.
  • Loading branch information
pedro committed Nov 26, 2023
1 parent d7d66d0 commit 02ae4a0
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
3 changes: 2 additions & 1 deletion circus.robocalc.robochart.textual.tests/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ source.. = src/,\
src-gen/,\
xtend-gen/
bin.includes = .,\
META-INF/
META-INF/,\
junit-platform.properties
bin.excludes = **/*.xtend
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
junit.jupiter.testclass.order.default=org.junit.jupiter.api.ClassOrderer$OrderAnnotation
5 changes: 3 additions & 2 deletions circus.robocalc.robochart.textual.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ Version Update 3.1.0 : Nov 2022
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
</plugin>
<!-- <plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<configuration>
<useUIHarness>false</useUIHarness>
<work>robochart-tests/</work>
<runOrder>alphabetical</runOrder>
</configuration>
</plugin>-->
</plugin>
<?ignore
<plugin>
<groupId>org.eclipse.tycho</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,31 @@ import org.junit.jupiter.api.^extension.ExtendWith
import circus.robocalc.robochart.RCPackage
import circus.robocalc.robochart.RoboChartPackage.Literals
import org.eclipse.emf.ecore.EClass
import org.junit.jupiter.api.TestMethodOrder
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.TestClassOrder
import org.junit.jupiter.api.ClassOrderer

@ExtendWith(InjectionExtension)
@InjectWith(RoboChartInjectorProvider)
@TestMethodOrder(OrderAnnotation)
@TestClassOrder(ClassOrderer.OrderAnnotation)
@Order(1)
class IntegrationTest {
// @Inject ParseHelper<RCPackage> parseHelper
@Inject extension SmartParserHelper<BasicPackage>
@Inject extension ValidationTestHelper

val top_dir = "robochart-tests/"

@Test
@Order(1)
def void testSimpleMachine() {
val dir = top_dir+"robochart/test-simple-machine"
TestRoboChartModel(dir)
}

@Test
def void AlphaAlgorithm() {
val dir = top_dir+"robochart/AlphaAlgorithm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ import org.eclipse.xtext.testing.validation.ValidationTestHelper
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
import org.eclipse.core.runtime.FileLocator
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.TestClassOrder
import org.junit.jupiter.api.ClassOrderer

@ExtendWith(InjectionExtension)
@InjectWith(RoboChartInjectorProvider)
@TestClassOrder(ClassOrderer.OrderAnnotation)
@Order(2)
class RoboChartParsingTest {
@Inject extension SmartParseHelper<RCPackage>
@Inject extension ValidationTestHelper
Expand Down Expand Up @@ -278,11 +284,12 @@ class SmartParseHelper<T extends EObject> extends ParseHelper<T> {
jar.close();
} else {
// treating case where the resource files are a project in the workspace
var url = classLoader.getResource(cleanPath);
var url = classLoader.getResource("lib/robochart");
if (url === null) {
val pathInLib = if (cleanPath.startsWith("lib/")) cleanPath.replaceFirst("lib/","") else cleanPath
url = classLoader.getResource(pathInLib);
url = classLoader.getResource("robochart");
}

url = FileLocator.toFileURL(url);
val path = Paths.get(url.toURI)
var Stream<Path> walk = Files.list(path);
for (var Iterator<Path> it = walk.iterator(); it.hasNext();) {
Expand All @@ -305,7 +312,7 @@ class SmartParseHelper<T extends EObject> extends ParseHelper<T> {

def createResourceSet() {
val rs = rsp.get();
addRoboChartLibrary(rs);
//addRoboChartLibrary(rs);
return rs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,29 @@ class SmartParserHelper<T extends EObject> extends ParseHelper<T> {
jar.close();
} else {
// treating case where the resource files are a project in the workspace
var url = classLoader.getResource("lib/robochart");
if (url === null) {
url = classLoader.getResource("robochart");
}

url = FileLocator.toFileURL(url);
val path = Paths.get(url.toURI)
var Stream<Path> walk = Files.list(path);
for (var Iterator<Path> it = walk.iterator(); it.hasNext();) {
val p = it.next()
val is = p.toUri().toURL.openStream;
val furi = URI.createFileURI(p.toUri.toURL.path)
val r = rs.createResource(furi)
r.load(is, rs.loadOptions)
}
walk.close();
// var url = classLoader.getResource("lib/robochart");
// if (url === null) {
// url = classLoader.getResource("robochart");
// }
//
// url = FileLocator.toFileURL(url);
// val path = Paths.get(url.toURI)
// var Stream<Path> walk = Files.list(path);
// for (var Iterator<Path> it = walk.iterator(); it.hasNext();) {
// val p = it.next()
// val is = p.toUri().toURL.openStream;
// val furi = URI.createFileURI(p.toUri.toURL.path)
// val r = rs.createResource(furi)
// r.load(is, rs.loadOptions)
// }
// walk.close();
}
}

def createResourceSet() {
val rs = rsp.get();
// loading robochart libraries
loadRoboChartLibrary(rs)
//loadRoboChartLibrary(rs)

return rs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class RoboChartScopeProvider extends AbstractRoboChartScopeProvider {
return scope
}
} else if (context instanceof Transition) {
delegateGetScope(context, reference)
val r = IScope::NULLSCOPE
if (reference === TRANSITION__SOURCE) {
if (context.eContainer instanceof NodeContainer) {
Expand Down

0 comments on commit 02ae4a0

Please sign in to comment.