re-shape of compiler pipeline
This commit is contained in:
parent
d22c7d16ef
commit
ca285f36dd
@ -1,63 +0,0 @@
|
||||
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 {
|
||||
|
||||
@Test
|
||||
void canonicalOrderMustExposeExpectedStageGroups() throws Exception {
|
||||
final var analyzeStages = stages("analyses");
|
||||
final var compileStages = stages("compile");
|
||||
final var buildStages = stages("build");
|
||||
|
||||
assertEquals(
|
||||
List.of(
|
||||
ResolveDepsPipelineStage.class,
|
||||
LoadSourcesPipelineStage.class,
|
||||
FrontendPhasePipelineStage.class),
|
||||
analyzeStages);
|
||||
|
||||
assertEquals(
|
||||
List.of(
|
||||
LowerToIRVMPipelineStage.class,
|
||||
OptimizeIRVMPipelineStage.class,
|
||||
EmitBytecodePipelineStage.class,
|
||||
LinkBytecodePipelineStage.class,
|
||||
VerifyBytecodePipelineStage.class),
|
||||
compileStages);
|
||||
|
||||
assertEquals(
|
||||
List.of(WriteBytecodeArtifactPipelineStage.class),
|
||||
buildStages);
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicSurfaceMustExposeExplicitEntryPointsWithoutRun() {
|
||||
final var methodNames = List.of(BuilderPipelineService.class.getMethods()).stream()
|
||||
.filter(method -> method.getDeclaringClass().equals(BuilderPipelineService.class))
|
||||
.map(Method::getName)
|
||||
.toList();
|
||||
|
||||
assertTrue(methodNames.contains("analyze"));
|
||||
assertTrue(methodNames.contains("compile"));
|
||||
assertTrue(methodNames.contains("build"));
|
||||
assertFalse(methodNames.contains("run"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Class<?>> stages(final String fieldName) throws Exception {
|
||||
final Field field = BuilderPipelineService.class.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
final var stages = (List<PipelineStage>) field.get(BuilderPipelineService.INSTANCE);
|
||||
return stages.stream().map(Object::getClass).toList();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user