basic for analyse
This commit is contained in:
+33
@@ -3,12 +3,15 @@ package p.studio.compiler.integration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import p.studio.compiler.messages.BuilderPipelineConfig;
|
||||
import p.studio.compiler.models.BuilderPipelineContext;
|
||||
import p.studio.compiler.source.identifiers.FileId;
|
||||
import p.studio.compiler.utilities.SourceProviderFactory;
|
||||
import p.studio.compiler.workspaces.BuilderPipelineService;
|
||||
import p.studio.utilities.logs.LogAggregator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -32,6 +35,36 @@ class MainProjectPipelineIntegrationTest {
|
||||
assertFalse(Files.exists(outputPath), "analyze must not write output: " + outputPath);
|
||||
}
|
||||
|
||||
@Test
|
||||
void analyzeShouldReturnStructuredDiagnosticsForOverlayDocumentWithoutThrowing() throws IOException {
|
||||
final var projectRoot = projectRoot();
|
||||
final var documentPath = projectRoot.resolve("src").resolve("main.pbs").toAbsolutePath().normalize();
|
||||
final var logs = bufferedLogs();
|
||||
final var invalidOverlay = """
|
||||
fn frame() -> void {
|
||||
let broken: int = ;
|
||||
}
|
||||
""";
|
||||
final var context = BuilderPipelineContext.fromConfig(new BuilderPipelineConfig(
|
||||
false,
|
||||
projectRoot.toString(),
|
||||
"core-v1",
|
||||
SourceProviderFactory.overlayUtf8(Map.of(documentPath, invalidOverlay))));
|
||||
|
||||
final var snapshot = assertDoesNotThrow(
|
||||
() -> BuilderPipelineService.INSTANCE.analyze(context, logs),
|
||||
() -> "analyze unexpectedly failed for overlay " + documentPath);
|
||||
|
||||
final var documentDiagnostics = snapshot.diagnostics().stream()
|
||||
.filter(issue -> issue.getFileId() != null)
|
||||
.filter(issue -> issue.getFileId() >= 0 && issue.getFileId() < snapshot.fileTable().size())
|
||||
.filter(issue -> snapshot.fileTable().get(new FileId(issue.getFileId())).getCanonPath().toAbsolutePath().normalize().equals(documentPath))
|
||||
.toList();
|
||||
|
||||
assertFalse(documentDiagnostics.isEmpty(), "overlay analysis must surface diagnostics for " + documentPath);
|
||||
assertTrue(documentDiagnostics.stream().anyMatch(issue -> issue.isError() && issue.getCode() != null && issue.getStart() != null && issue.getEnd() != null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void compileShouldProduceInMemoryBytecodeWithoutWritingProgramBytecode() throws IOException {
|
||||
final var projectRoot = projectRoot();
|
||||
|
||||
Reference in New Issue
Block a user