implements PLN-0106
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.49% (17397/28294)
* Branch Coverage: 52.32% (6724/12852)
* Lines of Code: 28294
* Cyclomatic Complexity: 11339
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 608
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good
JaCoCo Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 61.49% (17397/28294)
* Branch Coverage: 52.32% (6724/12852)
* Lines of Code: 28294
* Cyclomatic Complexity: 11339
#### Quality Gates Summary
Output truncated.
Test / Build skipped: 15, passed: 608
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good
This commit is contained in:
+2
-8
@@ -17,13 +17,7 @@ public class FrontendPhasePipelineStage implements PipelineStage {
|
||||
@Override
|
||||
public BuildingIssueSink run(final BuilderPipelineContext ctx, final LogAggregator logs) {
|
||||
final var frontedSpec = ctx.resolvedWorkspace.frontendSpec();
|
||||
final var service = FrontendRegistryService.getFrontendPhaseService(frontedSpec.getLanguageId());
|
||||
if (service.isEmpty()) {
|
||||
return BuildingIssueSink.empty()
|
||||
.report(builder -> builder
|
||||
.error(true)
|
||||
.message("[BUILD]: unable to find a service for frontend phase: " + frontedSpec.getLanguageId()));
|
||||
}
|
||||
final var provider = FrontendRegistryService.require(frontedSpec.getLanguageId());
|
||||
final var projectTable = ctx.resolvedWorkspace.graph().projectTable();
|
||||
final var fileTable = ctx.fileTable;
|
||||
final var frontendPhaseContext = new FrontendPhaseContext(
|
||||
@@ -36,7 +30,7 @@ public class FrontendPhasePipelineStage implements PipelineStage {
|
||||
assetSurfaceContextLoader.load(ctx.resolvedWorkspace.mainProject().getRootPath()));
|
||||
final var diagnostics = DiagnosticSink.empty();
|
||||
final var issues = BuildingIssueSink.empty();
|
||||
ctx.irBackend = service.get().compile(frontendPhaseContext, diagnostics, logs, issues);
|
||||
ctx.irBackend = provider.compiler().compile(frontendPhaseContext, diagnostics, logs, issues);
|
||||
logs.using(log).debug("Frontend phase completed successfully!");
|
||||
adaptDiagnostics(diagnostics, issues);
|
||||
return issues;
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package p.studio.compiler.specs;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
class FrontendProviderBoundaryTest {
|
||||
|
||||
@Test
|
||||
void commonModulesMustNotInstantiatePbsFrontendPhaseServiceDirectly() throws IOException {
|
||||
final var repoRoot = findRepoRoot(Path.of("").toAbsolutePath().normalize());
|
||||
final var commonSourceRoots = List.of(
|
||||
repoRoot.resolve("prometeu-compiler/prometeu-build-pipeline/src/main/java"),
|
||||
repoRoot.resolve("prometeu-compiler/prometeu-deps/src/main/java"),
|
||||
repoRoot.resolve("prometeu-studio/src/main/java"),
|
||||
repoRoot.resolve("prometeu-app/src/main/java"));
|
||||
|
||||
for (final var sourceRoot : commonSourceRoots) {
|
||||
if (!Files.exists(sourceRoot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try (final var files = Files.walk(sourceRoot)) {
|
||||
final var violations = files
|
||||
.filter(path -> path.toString().endsWith(".java"))
|
||||
.filter(path -> contains(path, "new PBSFrontendPhaseService("))
|
||||
.toList();
|
||||
if (!violations.isEmpty()) {
|
||||
fail("common modules must resolve frontend compiler behavior through FrontendProvider: " + violations);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean contains(final Path path, final String needle) {
|
||||
try {
|
||||
return Files.readString(path).contains(needle);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("failed to read " + path, e);
|
||||
}
|
||||
}
|
||||
|
||||
private Path findRepoRoot(final Path start) {
|
||||
var current = start;
|
||||
while (current != null) {
|
||||
if (Files.exists(current.resolve("settings.gradle.kts"))) {
|
||||
return current;
|
||||
}
|
||||
current = current.getParent();
|
||||
}
|
||||
fail("unable to locate repository root from " + start);
|
||||
return start;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user