implements PLN-0011 pipeline callsite and test migration
This commit is contained in:
-4
@@ -33,8 +33,4 @@ public class BuilderPipelineContext {
|
||||
public static BuilderPipelineContext fromConfig(final BuilderPipelineConfig config) {
|
||||
return new BuilderPipelineContext(config, config.sourceProviderFactory());
|
||||
}
|
||||
|
||||
public static BuilderPipelineContext compilerContext(final BuilderPipelineConfig config) {
|
||||
return fromConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ class BackendGateIIntegrationTest {
|
||||
}
|
||||
|
||||
private BytecodeModule emitFromBackend(final IRBackend backend) {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irBackend = backend;
|
||||
|
||||
final var lowerIssues = new LowerToIRVMPipelineStage().run(ctx, LogAggregator.empty());
|
||||
|
||||
+5
@@ -28,6 +28,7 @@ class MainProjectPipelineIntegrationTest {
|
||||
assertNotNull(snapshot.resolvedWorkspace(), "analyze must expose resolved workspace");
|
||||
assertNotNull(snapshot.fileTable(), "analyze must expose file table");
|
||||
assertNotNull(snapshot.irBackend(), "analyze must expose frontend semantic result");
|
||||
assertNotNull(snapshot.diagnostics(), "analyze must expose diagnostics collection");
|
||||
assertFalse(Files.exists(outputPath), "analyze must not write output: " + outputPath);
|
||||
}
|
||||
|
||||
@@ -43,6 +44,7 @@ class MainProjectPipelineIntegrationTest {
|
||||
() -> "compile unexpectedly failed for " + projectRoot);
|
||||
|
||||
assertNotNull(result.analysisSnapshot(), "compile must retain analysis snapshot");
|
||||
assertNotNull(result.diagnostics(), "compile must expose diagnostics collection");
|
||||
assertNotNull(result.bytecodeModule(), "compile must expose bytecode module");
|
||||
assertNotNull(result.bytecodeBytes(), "compile must expose bytecode bytes");
|
||||
assertTrue(result.bytecodeBytes().length > 0, "compile must expose non-empty bytecode bytes");
|
||||
@@ -60,6 +62,9 @@ class MainProjectPipelineIntegrationTest {
|
||||
final var result = assertDoesNotThrow(
|
||||
() -> BuilderPipelineService.INSTANCE.build(context, logs),
|
||||
() -> "build unexpectedly failed for " + projectRoot);
|
||||
assertNotNull(result.diagnostics(), "build must expose diagnostics collection");
|
||||
assertNotNull(result.compileResult(), "build must retain compile payload");
|
||||
assertNotNull(result.compileResult().analysisSnapshot(), "build must retain analysis payload");
|
||||
assertEquals(outputPath, result.bytecodeArtifactPath(), "build must expose written artifact path");
|
||||
assertTrue(Files.exists(outputPath), "build did not write output: " + outputPath);
|
||||
assertTrue(Files.size(outputPath) > 0, "build wrote empty bytecode file: " + outputPath);
|
||||
|
||||
+15
@@ -3,10 +3,13 @@ package p.studio.compiler.workspaces;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import p.studio.compiler.workspaces.stages.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class BuilderPipelineServiceOrderTest {
|
||||
|
||||
@@ -32,4 +35,16 @@ class BuilderPipelineServiceOrderTest {
|
||||
WriteBytecodeArtifactPipelineStage.class),
|
||||
stageTypes);
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicSurfaceMustExposeExplicitEntryPointsWithoutRun() {
|
||||
final var methodNames = List.of(BuilderPipelineService.class.getDeclaredMethods()).stream()
|
||||
.map(Method::getName)
|
||||
.toList();
|
||||
|
||||
assertTrue(methodNames.contains("analyze"));
|
||||
assertTrue(methodNames.contains("compile"));
|
||||
assertTrue(methodNames.contains("build"));
|
||||
assertFalse(methodNames.contains("run"));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -133,25 +133,25 @@ class BackendSafetyGateSUTest {
|
||||
}
|
||||
|
||||
private static p.studio.compiler.messages.BuildingIssueSink runLower(final IRBackend backend) {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irBackend = backend;
|
||||
return new LowerToIRVMPipelineStage().run(ctx, LogAggregator.empty());
|
||||
}
|
||||
|
||||
private static p.studio.compiler.messages.BuildingIssueSink runOptimize(final IRVMProgram program) {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irvm = program;
|
||||
return new OptimizeIRVMPipelineStage().run(ctx, LogAggregator.empty());
|
||||
}
|
||||
|
||||
private static p.studio.compiler.messages.BuildingIssueSink runEmit(final IRVMProgram program) {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.optimizedIrvm = program;
|
||||
return new EmitBytecodePipelineStage().run(ctx, LogAggregator.empty());
|
||||
}
|
||||
|
||||
private static byte[] emitBytes(final IRBackend backend) {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irBackend = backend;
|
||||
|
||||
final var lowerIssues = new LowerToIRVMPipelineStage().run(ctx, LogAggregator.empty());
|
||||
|
||||
+4
-4
@@ -14,7 +14,7 @@ class EmitBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenOptimizedIrvmIsMissing() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
final var stage = new EmitBytecodePipelineStage();
|
||||
|
||||
final var issues = stage.run(ctx, LogAggregator.empty());
|
||||
@@ -28,7 +28,7 @@ class EmitBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenInternalOpcodesRemain() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.optimizedIrvm = new IRVMProgram(true, BytecodeEmitter.EmissionPlan.empty());
|
||||
final var stage = new EmitBytecodePipelineStage();
|
||||
|
||||
@@ -42,7 +42,7 @@ class EmitBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenInternalOpcodesRemainEvenWithNonEmptyEmissionPlan() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.optimizedIrvm = new IRVMProgram(
|
||||
new p.studio.compiler.backend.irvm.IRVMModule(
|
||||
"experimental-v1",
|
||||
@@ -79,7 +79,7 @@ class EmitBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustEmitBytecodeWhenPreconditionsAreSatisfied() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.optimizedIrvm = new IRVMProgram(
|
||||
false,
|
||||
new BytecodeEmitter.EmissionPlan(
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ class LinkBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenBytecodeModuleIsMissing() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
final var stage = new LinkBytecodePipelineStage();
|
||||
|
||||
final var issues = stage.run(ctx, LogAggregator.empty());
|
||||
@@ -30,7 +30,7 @@ class LinkBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustReportHostcallIndexPrecheckFailure() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.bytecodeModule = new BytecodeModule(
|
||||
0,
|
||||
ReadOnlyList.empty(),
|
||||
|
||||
+5
-5
@@ -17,7 +17,7 @@ class LowerToIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenIrBackendIsMissing() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
final var stage = new LowerToIRVMPipelineStage();
|
||||
|
||||
final var issues = stage.run(ctx, LogAggregator.empty());
|
||||
@@ -31,7 +31,7 @@ class LowerToIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustLowerExecutableFunctionsToIrvm() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irBackend = IRBackend.builder()
|
||||
.entryPointModuleId(new p.studio.compiler.source.identifiers.ModuleId(0))
|
||||
.executableFunctions(ReadOnlyList.from(new IRBackendExecutableFunction(
|
||||
@@ -64,7 +64,7 @@ class LowerToIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustPropagateConfiguredVmProfileToLowering() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, ".", "experimental-v1"));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, ".", "experimental-v1"));
|
||||
ctx.irBackend = IRBackend.builder()
|
||||
.entryPointModuleId(new p.studio.compiler.source.identifiers.ModuleId(0))
|
||||
.executableFunctions(ReadOnlyList.from(new IRBackendExecutableFunction(
|
||||
@@ -97,7 +97,7 @@ class LowerToIRVMPipelineStageTest {
|
||||
@Test
|
||||
void runMustAttachSourceAttributionForLoweringFailure() {
|
||||
final var callSpan = new Span(new FileId(9), 12, 24);
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irBackend = IRBackend.builder()
|
||||
.entryPointModuleId(new p.studio.compiler.source.identifiers.ModuleId(0))
|
||||
.executableFunctions(ReadOnlyList.from(new IRBackendExecutableFunction(
|
||||
@@ -141,7 +141,7 @@ class LowerToIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustRejectCallWhenStackDoesNotProvideDeclaredArgs() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irBackend = IRBackend.builder()
|
||||
.entryPointModuleId(new p.studio.compiler.source.identifiers.ModuleId(0))
|
||||
.executableFunctions(ReadOnlyList.from(
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@ class OptimizeIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenIrvmIsMissing() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
final var stage = new OptimizeIRVMPipelineStage();
|
||||
|
||||
final var issues = stage.run(ctx, LogAggregator.empty());
|
||||
@@ -27,7 +27,7 @@ class OptimizeIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustProduceNoopOptimizedProgram() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irvm = new IRVMProgram(new IRVMModule(
|
||||
"core-v1",
|
||||
ReadOnlyList.from(new IRVMFunction(
|
||||
@@ -49,7 +49,7 @@ class OptimizeIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustRejectUnsupportedVmProfile() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.irvm = new IRVMProgram(new IRVMModule(
|
||||
"experimental",
|
||||
ReadOnlyList.from(new IRVMFunction(
|
||||
@@ -70,7 +70,7 @@ class OptimizeIRVMPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustAcceptSupportedNonDefaultVmProfile() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, ".", "experimental-v1"));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, ".", "experimental-v1"));
|
||||
ctx.irvm = new IRVMProgram(new IRVMModule(
|
||||
"experimental-v1",
|
||||
ReadOnlyList.from(new IRVMFunction(
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ class VerifyBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenBytecodeModuleIsMissing() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
final var stage = new VerifyBytecodePipelineStage();
|
||||
|
||||
final var issues = stage.run(ctx, LogAggregator.empty());
|
||||
@@ -30,7 +30,7 @@ class VerifyBytecodePipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustRejectRawSyscallInPreload() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.bytecodeModule = new BytecodeModule(
|
||||
0,
|
||||
ReadOnlyList.empty(),
|
||||
|
||||
+4
-4
@@ -20,7 +20,7 @@ class WriteBytecodeArtifactPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenRootProjectPathIsMissing() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.bytecodeBytes = new byte[] { 0x01 };
|
||||
|
||||
final var issues = new WriteBytecodeArtifactPipelineStage().run(ctx, LogAggregator.empty());
|
||||
@@ -33,7 +33,7 @@ class WriteBytecodeArtifactPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustFailWhenBytecodeInputIsMissing() {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.rootProjectPathCanon = tempDir;
|
||||
|
||||
final var issues = new WriteBytecodeArtifactPipelineStage().run(ctx, LogAggregator.empty());
|
||||
@@ -46,7 +46,7 @@ class WriteBytecodeArtifactPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustWriteBuildProgramPbxFromByteArray() throws Exception {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.rootProjectPathCanon = tempDir;
|
||||
ctx.bytecodeBytes = new byte[] { 0x50, 0x42, 0x58, 0x00 };
|
||||
|
||||
@@ -61,7 +61,7 @@ class WriteBytecodeArtifactPipelineStageTest {
|
||||
|
||||
@Test
|
||||
void runMustWriteBuildProgramPbxFromModuleWhenByteArrayIsMissing() throws Exception {
|
||||
final var ctx = BuilderPipelineContext.compilerContext(new BuilderPipelineConfig(false, "."));
|
||||
final var ctx = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(false, "."));
|
||||
ctx.rootProjectPathCanon = tempDir;
|
||||
ctx.bytecodeModule = new BytecodeModule(
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user