diff --git a/ros2rag.base/build.gradle b/ros2rag.base/build.gradle index 87e174cf6b7070f199f24805658fa691ce40db35..9e0bde27ffc2908022aa1a0148b6dc8acec2be35 100644 --- a/ros2rag.base/build.gradle +++ b/ros2rag.base/build.gradle @@ -157,5 +157,3 @@ jastadd { } generateAst.dependsOn relast - -apply from: 'test.build.gradle' diff --git a/ros2rag.base/src/main/java/org/jastadd/ros2rag/compiler/Compiler.java b/ros2rag.base/src/main/java/org/jastadd/ros2rag/compiler/Compiler.java index 9fd90f037abad335414f1c54fea0a548c34b2909..a4f5bdc7f53251fecbd0aaf86d98faf017684259 100644 --- a/ros2rag.base/src/main/java/org/jastadd/ros2rag/compiler/Compiler.java +++ b/ros2rag.base/src/main/java/org/jastadd/ros2rag/compiler/Compiler.java @@ -71,12 +71,17 @@ public class Compiler { printMessage("Writing output files"); // copy MqttUpdater into outputDir + final String mqttUpdaterFileName = "MqttUpdater.jadd"; try { - Files.copy(Paths.get("src", "main", "resources", "MqttUpdater.jadd"), - Paths.get(outputDir, "MqttUpdater.jadd"), + InputStream inputStream = Compiler.class.getClassLoader().getResourceAsStream(mqttUpdaterFileName); + if (inputStream == null) { + throw new CompilerException("Could not open " + mqttUpdaterFileName); + } + Files.copy(inputStream, + Paths.get(outputDir, mqttUpdaterFileName), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { - throw new CompilerException("Could not copy MqttUpdater.java", e); + throw new CompilerException("Could not copy " + mqttUpdaterFileName, e); } writeToFile(outputDir + "/Grammar.relast", ros2Rag.getProgram().generateAbstractGrammar()); writeToFile(outputDir + "/ROS2RAG.jadd", ros2Rag.generateAspect(optionRootNode.getValue())); diff --git a/ros2rag.base/test.build.gradle b/ros2rag.tests/build.gradle similarity index 86% rename from ros2rag.base/test.build.gradle rename to ros2rag.tests/build.gradle index 04252f02b04ded4c49d6ff7860935f6dd480eef8..bedeb8ce63ceaaa9ebe48fbd7e8c7448a406b262 100644 --- a/ros2rag.base/test.build.gradle +++ b/ros2rag.tests/build.gradle @@ -1,12 +1,25 @@ import org.jastadd.relast.plugin.RelastPlugin import org.jastadd.relast.plugin.RelastTest +apply plugin: 'jastadd' +apply plugin: 'application' apply plugin: RelastPlugin -relastTest { - compilerLocation = '../libs/relast.jar' +sourceCompatibility = 1.8 + +repositories { + jcenter() +} + +buildscript { + repositories.jcenter() + dependencies { + classpath 'org.jastadd:jastaddgradle:1.13.3' + } } dependencies { + runtime 'org.jastadd:jastadd:2.3.4' + implementation project(':ros2rag.base') testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0' testImplementation 'org.assertj:assertj-core:3.12.1' @@ -15,6 +28,16 @@ dependencies { testImplementation 'com.google.protobuf:protobuf-java:3.0.0' } +test { + useJUnitPlatform() + + maxHeapSize = '1G' +} + +relastTest { + compilerLocation = '../libs/relast.jar' +} + sourceSets { test { java.srcDir "src/test/java-gen" @@ -22,7 +45,6 @@ sourceSets { } task preprocessExampleTest(type: JavaExec, group: 'verification') { - doFirst { delete 'src/test/02-after-ros2rag/example/Grammar.relast', 'src/test/02-after-ros2rag/example/MqttUpdater.java', diff --git a/ros2rag.base/src/test/.gitignore b/ros2rag.tests/src/test/.gitignore similarity index 100% rename from ros2rag.base/src/test/.gitignore rename to ros2rag.tests/src/test/.gitignore diff --git a/ros2rag.base/src/test/01-input/example/Example.jadd b/ros2rag.tests/src/test/01-input/example/Example.jadd similarity index 100% rename from ros2rag.base/src/test/01-input/example/Example.jadd rename to ros2rag.tests/src/test/01-input/example/Example.jadd diff --git a/ros2rag.base/src/test/01-input/example/Example.relast b/ros2rag.tests/src/test/01-input/example/Example.relast similarity index 100% rename from ros2rag.base/src/test/01-input/example/Example.relast rename to ros2rag.tests/src/test/01-input/example/Example.relast diff --git a/ros2rag.base/src/test/01-input/example/Example.ros2rag b/ros2rag.tests/src/test/01-input/example/Example.ros2rag similarity index 100% rename from ros2rag.base/src/test/01-input/example/Example.ros2rag rename to ros2rag.tests/src/test/01-input/example/Example.ros2rag diff --git a/ros2rag.base/src/test/01-input/example/linkstate.proto b/ros2rag.tests/src/test/01-input/example/linkstate.proto similarity index 100% rename from ros2rag.base/src/test/01-input/example/linkstate.proto rename to ros2rag.tests/src/test/01-input/example/linkstate.proto diff --git a/ros2rag.base/src/test/01-input/example/robotconfig.proto b/ros2rag.tests/src/test/01-input/example/robotconfig.proto similarity index 100% rename from ros2rag.base/src/test/01-input/example/robotconfig.proto rename to ros2rag.tests/src/test/01-input/example/robotconfig.proto diff --git a/ros2rag.base/src/test/java/org/jastadd/ros2rag/tests/ExampleTest.java b/ros2rag.tests/src/test/java/org/jastadd/ros2rag/tests/ExampleTest.java similarity index 100% rename from ros2rag.base/src/test/java/org/jastadd/ros2rag/tests/ExampleTest.java rename to ros2rag.tests/src/test/java/org/jastadd/ros2rag/tests/ExampleTest.java diff --git a/ros2rag.base/src/test/java/org/jastadd/ros2rag/tests/RosToRagTest.java b/ros2rag.tests/src/test/java/org/jastadd/ros2rag/tests/RosToRagTest.java similarity index 100% rename from ros2rag.base/src/test/java/org/jastadd/ros2rag/tests/RosToRagTest.java rename to ros2rag.tests/src/test/java/org/jastadd/ros2rag/tests/RosToRagTest.java diff --git a/settings.gradle b/settings.gradle index 558a492cc410a682b33c2a452474c8e9eade2bed..d6c40a5bd5730595c4a10141801c3635e4069acd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,8 @@ rootProject.name = 'ros2rag' +include 'relast.preprocessor' include 'ros2rag.base' +include 'ros2rag.tests' include 'ros2rag.example' include 'ros2rag.senderstub' include 'ros2rag.receiverstub' -include 'relast.preprocessor'