diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-03-24 14:10:30 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-03-24 14:10:30 +0000 |
| commit | 04cf66d6b53121998b33889a5495aaef3925cdfd (patch) | |
| tree | 71f827e2486627eb794c3f5b62e74ccab349d5ec /src/test/java | |
| parent | cb44def5d662e9ec15cf1d97d735c6deb129c302 (diff) | |
Use profiles when compiling
Diffstat (limited to 'src/test/java')
3 files changed, 15 insertions, 5 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/ExampleTests.java b/src/test/java/org/shedlang/compiler/backends/ExampleTests.java index 1190a67f..0d7eba56 100644 --- a/src/test/java/org/shedlang/compiler/backends/ExampleTests.java +++ b/src/test/java/org/shedlang/compiler/backends/ExampleTests.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.TestFactory; import org.shedlang.compiler.ShedCompiler; +import org.shedlang.compiler.config.ProfileConfig; import org.shedlang.compiler.config.ProjectConfig; import org.shedlang.compiler.errors.CompilerError; import org.shedlang.compiler.filesystem.ShedCompilerFiles; @@ -16,6 +17,7 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.stream.Stream; import static org.zwobble.precisely.AssertThat.assertThat; @@ -44,7 +46,7 @@ public abstract class ExampleTests { var config = ProjectConfig.read(exampleDirectory.toPath()); for (var example : config.examples()) { try { - compiler.compile(exampleDirectory.toPath(), backend, "mark-and-sweep"); + compiler.compile(exampleDirectory.toPath(), backend, Optional.empty()); } catch (CompilerError error) { if (example.expectedError().isPresent()) { assertThat(error.getMessage(), equalTo(example.expectedError().get())); @@ -55,7 +57,12 @@ public abstract class ExampleTests { throw error; } - var binPath = config.targetDir().resolve(backend.targetName()).resolve(example.bin()).toString(); + // TODO: remove duplicated generation of target binary path + var binPath = config.targetDir() + .resolve(backend.targetName()) + .resolve(ProfileConfig.DEFAULT.name()) + .resolve(example.bin()) + .toString(); var result = runExampleBinary(binPath).throwOnError(); assertThat(result.stdout(), equalTo(example.expectedOutput().orElseThrow())); } diff --git a/src/test/java/org/shedlang/compiler/backends/llvm/PatioToLlvmTests.java b/src/test/java/org/shedlang/compiler/backends/llvm/PatioToLlvmTests.java index b4c27e65..71dd9320 100644 --- a/src/test/java/org/shedlang/compiler/backends/llvm/PatioToLlvmTests.java +++ b/src/test/java/org/shedlang/compiler/backends/llvm/PatioToLlvmTests.java @@ -10,6 +10,7 @@ import org.shedlang.compiler.backends.llvm.ir.ast.operands.LlvmOperandInt; import org.shedlang.compiler.backends.llvm.ir.ast.operands.LlvmVariableGlobal; import org.shedlang.compiler.backends.llvm.ir.ast.types.LlvmTypes; import org.shedlang.compiler.backends.paths.PartialTargetPath; +import org.shedlang.compiler.config.GcConfig; import org.shedlang.compiler.filesystem.ShedCompilerFiles; import org.shedlang.compiler.patio.PatioCompilationUnit; import org.shedlang.compiler.patio.PatioExampleTests; @@ -62,16 +63,17 @@ public abstract class PatioToLlvmTests extends PatioExampleTests { var executablePath = workingDirectory.resolve("main"); + var gcConfig = GcConfig.DEFAULT; LlvmBackend.forTarget(this.llvmTarget()).link( List.of( objectFilePath, ShedCompilerFiles.targetDir( this.llvmTarget().targetName(), - "mark-and-sweep" + gcConfig ).resolve("libpatio_test.a") ), executablePath, - "mark-and-sweep" + gcConfig ); return TestProcessRunner.runCaptureOutput(List.of(executablePath.toString())); diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/PatioToWasmTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/PatioToWasmTests.java index bc7c572f..829c69e6 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/PatioToWasmTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/PatioToWasmTests.java @@ -7,6 +7,7 @@ import org.shedlang.compiler.backends.wasm.structure.ast.instructions.WasmInstru import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmFuncName; import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmFunction; import org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatTesting; +import org.shedlang.compiler.config.GcConfig; import org.shedlang.compiler.patio.PatioCompilationUnit; import org.shedlang.compiler.patio.PatioExampleTests; import org.shedlang.compiler.testing.ExecutionResult; @@ -49,7 +50,7 @@ public abstract class PatioToWasmTests extends PatioExampleTests { WasmBackend.forTarget(wasmTarget()).link( List.of(objectPath), executablePath, - "mark-and-sweep" + GcConfig.DEFAULT ); WasmBinaryFormatTesting.validate(executablePath, wasmTarget()); |
