Skip to content
Snippets Groups Projects
Commit 4201f067 authored by René Schöne's avatar René Schöne
Browse files

Resolve problem with relative paths, second try.

- use absolute paths
parent ed680b38
No related branches found
No related tags found
No related merge requests found
Pipeline #6611 passed
...@@ -13,6 +13,7 @@ import java.nio.file.*; ...@@ -13,6 +13,7 @@ import java.nio.file.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* RelAst Test Task * RelAst Test Task
...@@ -165,6 +166,10 @@ public class RelastTest extends DefaultTask { ...@@ -165,6 +166,10 @@ public class RelastTest extends DefaultTask {
private final String[] genSuffixes = {".ast", ".jadd", "RefResolver.jadd", "ResolverStubs.jrag", "Serializer.jadd"}; private final String[] genSuffixes = {".ast", ".jadd", "RefResolver.jadd", "ResolverStubs.jrag", "Serializer.jadd"};
private Path pathToAbsoluteProject(String filename) {
return Paths.get(getProject().getProjectDir().getAbsolutePath(), filename);
}
@TaskAction @TaskAction
void runTest() throws IOException { void runTest() throws IOException {
setGroup("verification"); setGroup("verification");
...@@ -179,7 +184,7 @@ public class RelastTest extends DefaultTask { ...@@ -179,7 +184,7 @@ public class RelastTest extends DefaultTask {
// first, delete generated files // first, delete generated files
List<Path> genFiles = new ArrayList<>(); List<Path> genFiles = new ArrayList<>();
for (String suffix : genSuffixes) { for (String suffix : genSuffixes) {
genFiles.add(Paths.get(absoluteProjectPath, getGrammarName() + suffix)); genFiles.add(pathToAbsoluteProject(getGrammarName() + suffix));
} }
if (isVerbose()) { if (isVerbose()) {
System.out.println("gen files: " + genFiles); System.out.println("gen files: " + genFiles);
...@@ -191,8 +196,8 @@ public class RelastTest extends DefaultTask { ...@@ -191,8 +196,8 @@ public class RelastTest extends DefaultTask {
} }
}); });
// create output directories, if not existing // create output directories, if not existing
createDirectory(Paths.get(getOutputDir())); createDirectory(pathToAbsoluteProject(getOutputDir()));
createDirectory(Paths.get(getGrammarName()).getParent()); createDirectory(pathToAbsoluteProject(getGrammarName()).getParent());
if (isVerbose()) { if (isVerbose()) {
System.out.println("Pre processing, running relast"); System.out.println("Pre processing, running relast");
} }
...@@ -209,7 +214,7 @@ public class RelastTest extends DefaultTask { ...@@ -209,7 +214,7 @@ public class RelastTest extends DefaultTask {
} else { } else {
javaExecSpec.setMain("org.jastadd.relast.compiler.Compiler"); javaExecSpec.setMain("org.jastadd.relast.compiler.Compiler");
} }
args.addAll(getRelastFiles()); args.addAll(getRelastFiles().stream().map(this::pathToAbsoluteProject).collect(Collectors.toList()));
args.add("--quiet"); args.add("--quiet");
if (isWriteToFile()) { if (isWriteToFile()) {
args.add("--file"); args.add("--file");
...@@ -229,7 +234,7 @@ public class RelastTest extends DefaultTask { ...@@ -229,7 +234,7 @@ public class RelastTest extends DefaultTask {
if (isSet(getSerializer())) { if (isSet(getSerializer())) {
args.add("--serializer=" + getSerializer()); args.add("--serializer=" + getSerializer());
} }
args.add("--grammarName=" + getGrammarName()); args.add("--grammarName=" + pathToAbsoluteProject(getGrammarName()));
if (isVerbose()) { if (isVerbose()) {
System.out.println("Start relast with args: " + args); System.out.println("Start relast with args: " + args);
} }
...@@ -250,13 +255,13 @@ public class RelastTest extends DefaultTask { ...@@ -250,13 +255,13 @@ public class RelastTest extends DefaultTask {
javaExecSpec.setClasspath(runtimeClasspath); javaExecSpec.setClasspath(runtimeClasspath);
javaExecSpec.setMain("org.jastadd.JastAdd"); javaExecSpec.setMain("org.jastadd.JastAdd");
List<Object> args = new ArrayList<>(); List<Object> args = new ArrayList<>();
args.add("--o=" + getOutputDir()); args.add("--o=" + pathToAbsoluteProject(getOutputDir()));
args.add("--package=" + getPackageName()); args.add("--package=" + getPackageName());
if (isSet(getJastAddList())) { if (isSet(getJastAddList())) {
args.add("--List=" + getJastAddList()); args.add("--List=" + getJastAddList());
} }
args.addAll(genFiles); args.addAll(genFiles);
args.addAll(getMoreInputFiles()); args.addAll(getMoreInputFiles().stream().map(this::pathToAbsoluteProject).collect(Collectors.toList()));
if (isVerbose()) { if (isVerbose()) {
System.out.println("Start JastAdd with args: " + args); System.out.println("Start JastAdd with args: " + args);
} }
......
...@@ -87,6 +87,7 @@ task preprocessExampleTest(type: JavaExec, group: 'verification') { ...@@ -87,6 +87,7 @@ task preprocessExampleTest(type: JavaExec, group: 'verification') {
//} //}
task compileExampleTest(type: RelastTest) { task compileExampleTest(type: RelastTest) {
verbose = true
useJastAddNames = true useJastAddNames = true
relastFiles 'src/test/02-after-ros2rag/example/Grammar.relast' relastFiles 'src/test/02-after-ros2rag/example/Grammar.relast'
grammarName = 'src/test/03-after-relast/example/example' grammarName = 'src/test/03-after-relast/example/example'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment