From 61b437d55e520ed082ddee7fccd7aca1a4658ed6 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 30 Jun 2026 20:21:29 +0100 Subject: Extract verifyOutput --- .../org/zwobble/hobgoblin/compiler/ExampleTests.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') 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 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)); -- cgit v1.2.3