Commit 942f1368 authored by René Schöne's avatar René Schöne
Browse files

Fix test Errors, and use junit 5 assertions.

parent 9acf8567
Pipeline #6934 failed with stage
in 4 minutes and 12 seconds
......@@ -11,8 +11,8 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case "defaultOnlyRead".
......
......@@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Test case "defaultOnlyRead".
......
......@@ -4,6 +4,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jastadd.ros2rag.compiler.Compiler;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.File;
......@@ -16,6 +17,7 @@ import java.util.stream.Collectors;
import static org.jastadd.ros2rag.tests.TestUtils.exec;
import static org.jastadd.ros2rag.tests.TestUtils.readFile;
import static org.junit.jupiter.api.Assertions.assertTrue;
class Errors {
......@@ -24,6 +26,12 @@ class Errors {
private static final String INPUT_DIRECTORY = "./src/test/01-input/errors/";
private static final String OUTPUT_DIRECTORY = "./src/test/02-after-ros2rag/errors/";
@BeforeAll
public static void createOutputDirectory() {
File outputDirectory = new File(OUTPUT_DIRECTORY);
assertTrue((outputDirectory.exists() && outputDirectory.isDirectory()) || outputDirectory.mkdir());
}
@Test
void testStandardErrors() throws IOException {
test("Errors", "A");
......
......@@ -11,7 +11,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Test case "example".
......
......@@ -7,8 +7,8 @@ import read1write2.ast.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case "read-1-write-2".
......
......@@ -7,8 +7,8 @@ import read2write1.ast.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case "read-1-write-2".
......
package org.jastadd.ros2rag.tests;
import org.jastadd.ros2rag.compiler.Compiler;
import org.jastadd.ros2rag.compiler.options.CommandLine;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.nio.file.Paths;
import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Disabled("migrating build logic from test to build, this test is disabled for now")
public class RosToRagTest {
void transform(String inputGrammar, String inputRos2Rag, String rootNode, String outputDir) throws CommandLine.CommandLineException, Compiler.CompilerException {
System.out.println(Paths.get(".").toAbsolutePath());
assertTrue(Paths.get(inputGrammar).toFile().exists(), "input grammar does not exist");
File outputDirFile = Paths.get(outputDir).toFile();
if (outputDirFile.exists()) {
assertTrue(outputDirFile.isDirectory());
if (Objects.requireNonNull(outputDirFile.list(), "Could not read output directory").length != 0) {
System.out.println("output directory is not empty!");
}
} else {
assertTrue(outputDirFile.mkdir());
}
String[] args = {
"--outputDir=" + outputDir,
"--inputGrammar=" + inputGrammar,
"--inputRos2Rag=" + inputRos2Rag,
"--rootNode=" + rootNode
};
new Compiler().run(args);
}
@Test
void transformMinimalExample() throws CommandLine.CommandLineException, Compiler.CompilerException {
transform("src/test/resources/Example.relast",
"src/test/resources/Example.ros2rag",
"Model",
"src/test/resources/out");
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment