From a882cdc3b3c22a89ea9ab9da483ea6d325e9746e Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Wed, 6 May 2020 17:43:50 +0200 Subject: [PATCH] Move tests to separate Gradle module. --- ros2rag.base/build.gradle | 2 -- .../jastadd/ros2rag/compiler/Compiler.java | 11 ++++++-- .../build.gradle | 28 +++++++++++++++++-- .../src/test/.gitignore | 0 .../src/test/01-input/example/Example.jadd | 0 .../src/test/01-input/example/Example.relast | 0 .../src/test/01-input/example/Example.ros2rag | 0 .../src/test/01-input/example/linkstate.proto | 0 .../test/01-input/example/robotconfig.proto | 0 .../jastadd/ros2rag/tests/ExampleTest.java | 0 .../jastadd/ros2rag/tests/RosToRagTest.java | 0 settings.gradle | 3 +- 12 files changed, 35 insertions(+), 9 deletions(-) rename ros2rag.base/test.build.gradle => ros2rag.tests/build.gradle (86%) rename {ros2rag.base => ros2rag.tests}/src/test/.gitignore (100%) rename {ros2rag.base => ros2rag.tests}/src/test/01-input/example/Example.jadd (100%) rename {ros2rag.base => ros2rag.tests}/src/test/01-input/example/Example.relast (100%) rename {ros2rag.base => ros2rag.tests}/src/test/01-input/example/Example.ros2rag (100%) rename {ros2rag.base => ros2rag.tests}/src/test/01-input/example/linkstate.proto (100%) rename {ros2rag.base => ros2rag.tests}/src/test/01-input/example/robotconfig.proto (100%) rename {ros2rag.base => ros2rag.tests}/src/test/java/org/jastadd/ros2rag/tests/ExampleTest.java (100%) rename {ros2rag.base => ros2rag.tests}/src/test/java/org/jastadd/ros2rag/tests/RosToRagTest.java (100%) diff --git a/ros2rag.base/build.gradle b/ros2rag.base/build.gradle index 87e174c..9e0bde2 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 9fd90f0..a4f5bdc 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 04252f0..bedeb8c 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 558a492..d6c40a5 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' -- GitLab