From c37a1a46853e4410c060e2ee6d71c033f57eb2eb Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 16 Sep 2023 15:23:15 +0100 Subject: Move ExecutionResult to testing package --- .../java/org/shedlang/compiler/backends/ExampleTests.java | 2 +- .../org/shedlang/compiler/backends/llvm/ExecutionResult.java | 11 ----------- .../compiler/backends/llvm/LlvmPatioCodeGenTests.java | 1 + .../compiler/backends/wasm/WasmPatioCodeGenTests.java | 2 +- .../java/org/shedlang/compiler/patio/PatioExampleTests.java | 2 +- .../java/org/shedlang/compiler/testing/ExecutionResult.java | 11 +++++++++++ .../java/org/shedlang/compiler/testing/TestProcessRunner.java | 2 -- 7 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 src/test/java/org/shedlang/compiler/backends/llvm/ExecutionResult.java create mode 100644 src/test/java/org/shedlang/compiler/testing/ExecutionResult.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/backends/ExampleTests.java b/src/test/java/org/shedlang/compiler/backends/ExampleTests.java index f3903746..5a6a7cbc 100644 --- a/src/test/java/org/shedlang/compiler/backends/ExampleTests.java +++ b/src/test/java/org/shedlang/compiler/backends/ExampleTests.java @@ -3,7 +3,7 @@ package org.shedlang.compiler.backends; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; import org.shedlang.compiler.ShedCompiler; -import org.shedlang.compiler.backends.llvm.ExecutionResult; +import org.shedlang.compiler.testing.ExecutionResult; import org.shedlang.compiler.config.ProjectConfig; import org.shedlang.compiler.errors.SourceError; import org.shedlang.compiler.filesystem.ShedCompilerFiles; diff --git a/src/test/java/org/shedlang/compiler/backends/llvm/ExecutionResult.java b/src/test/java/org/shedlang/compiler/backends/llvm/ExecutionResult.java deleted file mode 100644 index d977d70d..00000000 --- a/src/test/java/org/shedlang/compiler/backends/llvm/ExecutionResult.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.shedlang.compiler.backends.llvm; - -public record ExecutionResult(int exitCode, String stdout, String stderr) { - public ExecutionResult throwOnError() { - if (exitCode == 0) { - return this; - } else { - throw new AssertionError("exit code was " + exitCode + "\nstdout:\n" + stdout + "\nstderr:\n" + stderr); - } - } -} diff --git a/src/test/java/org/shedlang/compiler/backends/llvm/LlvmPatioCodeGenTests.java b/src/test/java/org/shedlang/compiler/backends/llvm/LlvmPatioCodeGenTests.java index 56bcfe6b..d6c13d78 100644 --- a/src/test/java/org/shedlang/compiler/backends/llvm/LlvmPatioCodeGenTests.java +++ b/src/test/java/org/shedlang/compiler/backends/llvm/LlvmPatioCodeGenTests.java @@ -11,6 +11,7 @@ import org.shedlang.compiler.backends.llvm.ir.ast.types.LlvmTypes; import org.shedlang.compiler.filesystem.ShedCompilerFiles; import org.shedlang.compiler.patio.PatioExampleTests; import org.shedlang.compiler.patio.ast.PatioCompilationUnit; +import org.shedlang.compiler.testing.ExecutionResult; import org.shedlang.compiler.testing.TestProcessRunner; import java.io.IOException; diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java index 7df0f65c..a0ef3592 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java @@ -1,6 +1,6 @@ package org.shedlang.compiler.backends.wasm; -import org.shedlang.compiler.backends.llvm.ExecutionResult; +import org.shedlang.compiler.testing.ExecutionResult; import org.shedlang.compiler.backends.wasm.structure.WasmBinaryFormat; import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmCall; import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmExpression; diff --git a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java index abb0807f..2718e85f 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java @@ -1,7 +1,7 @@ package org.shedlang.compiler.patio; import org.junit.jupiter.api.Test; -import org.shedlang.compiler.backends.llvm.ExecutionResult; +import org.shedlang.compiler.testing.ExecutionResult; import org.shedlang.compiler.patio.ast.PatioCompilationUnit; import org.shedlang.compiler.patio.ast.PatioFunctionDefinition; import org.shedlang.compiler.patio.ast.types.PatioTypes; diff --git a/src/test/java/org/shedlang/compiler/testing/ExecutionResult.java b/src/test/java/org/shedlang/compiler/testing/ExecutionResult.java new file mode 100644 index 00000000..f4a37385 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/testing/ExecutionResult.java @@ -0,0 +1,11 @@ +package org.shedlang.compiler.testing; + +public record ExecutionResult(int exitCode, String stdout, String stderr) { + public ExecutionResult throwOnError() { + if (exitCode == 0) { + return this; + } else { + throw new AssertionError("exit code was " + exitCode + "\nstdout:\n" + stdout + "\nstderr:\n" + stderr); + } + } +} diff --git a/src/test/java/org/shedlang/compiler/testing/TestProcessRunner.java b/src/test/java/org/shedlang/compiler/testing/TestProcessRunner.java index 1c84e16f..620ee64a 100644 --- a/src/test/java/org/shedlang/compiler/testing/TestProcessRunner.java +++ b/src/test/java/org/shedlang/compiler/testing/TestProcessRunner.java @@ -1,7 +1,5 @@ package org.shedlang.compiler.testing; -import org.shedlang.compiler.backends.llvm.ExecutionResult; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.List; -- cgit v1.2.3