summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-06-30 20:21:29 +0100
committerMichael Williamson <mike@zwobble.org>2026-06-30 20:21:29 +0100
commit61b437d55e520ed082ddee7fccd7aca1a4658ed6 (patch)
treef843a8d5508fb574fc58f7c92d92de4b3ef41e90 /src/test
parent5acf8606c8bbd51d080f1cfe77b5a49c89c93c7b (diff)
Extract verifyOutput
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java
index d40eae0..55944f7 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java
@@ -30,15 +30,23 @@ public class ExampleTests {
}
private void verifyJavaOutput(ExampleSet exampleSet) throws NoSuchAlgorithmException, IOException, InterruptedException {
- var javaProjectPath = exampleSet.path().resolve("output/java");
+ verifyOutput(exampleSet, "java", List.of("mvn", "compile"));
+ }
+
+ private void verifyOutput(
+ ExampleSet exampleSet,
+ String name,
+ List<String> command
+ ) throws NoSuchAlgorithmException, IOException, InterruptedException {
+ var outputPath = exampleSet.path().resolve("output").resolve(name);
- if (!javaProjectPath.toFile().exists()) {
+ if (!outputPath.toFile().exists()) {
return;
}
- var currentHash = hashJavaProject(javaProjectPath);
+ var currentHash = hashJavaProject(outputPath);
- var lastTestRunPath = javaProjectPath.resolve("last-test-run.properties");
+ var lastTestRunPath = outputPath.resolve("last-test-run.properties");
var lastTestRun = readLastTestRun(lastTestRunPath);
if (lastTestRun.isPresent() && lastTestRun.get().pass && lastTestRun.get().hash.equals(currentHash)) {
@@ -46,8 +54,8 @@ public class ExampleTests {
}
try {
- TestProcessRunner.command(List.of("mvn", "compile"))
- .cwd(javaProjectPath)
+ TestProcessRunner.command(command)
+ .cwd(outputPath)
.runCaptureOutput()
.throwOnError();
writeLastTestRun(lastTestRunPath, new LastTestRun(currentHash, true));