diff -r 02b000e40e5e -r 3ca85da78515 src/test/java/de/unixwork/uwproj/RegressionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/de/unixwork/uwproj/RegressionTest.java Wed Sep 06 21:08:04 2023 +0200 @@ -0,0 +1,39 @@ +package de.unixwork.uwproj; + +import org.junit.jupiter.api.Test; + +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Objects; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class RegressionTest { + + private void goldenSampleTest(String xml, String gs) throws Exception { + final var contents = new ByteArrayOutputStream(); + try (var out = new BufferedWriter(new OutputStreamWriter(contents))) { + Main.writeConfigureScript(out, "test/make/configure.vm", Main.loadProjectFile("test/make/" + xml)); + } + assertEquals( + Files.readString(Path.of( + Objects.requireNonNull(RegressionTest.class.getClassLoader().getResource("golden-sample/" + gs)).toURI() + )), + contents.toString(StandardCharsets.UTF_8) + ); + } + + @Test + void projectXmlOutput() throws Exception { + goldenSampleTest("project.xml", "configure"); + } + + @Test + void project2XmlOutput() throws Exception { + goldenSampleTest("project2.xml", "configure2"); + } +}