From 88bf9fbd452c6439c55235dc153565d1152d694a Mon Sep 17 00:00:00 2001 From: bQUARKz Date: Tue, 7 Apr 2026 06:06:02 +0100 Subject: [PATCH] fix tests --- .../execution/StudioPlayStopCoordinator.java | 18 ++++++++++---- .../studio/shipper/StudioShipperService.java | 2 ++ .../StudioPlayStopCoordinatorTest.java | 24 ++++++++++--------- .../EditorDocumentHighlightingRouterTest.java | 19 ++++++++++----- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/prometeu-studio/src/main/java/p/studio/execution/StudioPlayStopCoordinator.java b/prometeu-studio/src/main/java/p/studio/execution/StudioPlayStopCoordinator.java index e4f0f99a..4c07e030 100644 --- a/prometeu-studio/src/main/java/p/studio/execution/StudioPlayStopCoordinator.java +++ b/prometeu-studio/src/main/java/p/studio/execution/StudioPlayStopCoordinator.java @@ -36,6 +36,7 @@ public final class StudioPlayStopCoordinator { private final StudioBackgroundTasks backgroundTasks; private final Consumer workspaceSelector; private final Consumer lifecyclePublisher; + private final boolean preflightRuntime; private StudioRuntimeProcessHandle activeProcess; private boolean stopRequested; @@ -48,12 +49,13 @@ public final class StudioPlayStopCoordinator { projectReference, projectSetup, executionSession, - new StudioShipperService()::prepare, + (project, sink) -> new StudioShipperService().prepare(project, sink), new p.studio.debug.runtime.StudioRuntimeHandshakeService(), new StudioExternalRuntimeProcessLauncher(), Container.backgroundTasks(), workspaceSelector, - event -> Container.eventBus().publish(event)); + event -> Container.eventBus().publish(event), + true); } StudioPlayStopCoordinator( @@ -65,7 +67,8 @@ public final class StudioPlayStopCoordinator { final StudioRuntimeProcessLauncher runtimeProcessLauncher, final StudioBackgroundTasks backgroundTasks, final Consumer workspaceSelector, - final Consumer lifecyclePublisher) { + final Consumer lifecyclePublisher, + final boolean preflightRuntime) { this.projectReference = Objects.requireNonNull(projectReference, "projectReference"); this.projectSetup = Objects.requireNonNull(projectSetup, "projectSetup"); this.executionSession = Objects.requireNonNull(executionSession, "executionSession"); @@ -75,6 +78,7 @@ public final class StudioPlayStopCoordinator { this.backgroundTasks = Objects.requireNonNull(backgroundTasks, "backgroundTasks"); this.workspaceSelector = Objects.requireNonNull(workspaceSelector, "workspaceSelector"); this.lifecyclePublisher = Objects.requireNonNull(lifecyclePublisher, "lifecyclePublisher"); + this.preflightRuntime = preflightRuntime; } public void play() { @@ -121,7 +125,7 @@ public final class StudioPlayStopCoordinator { } executionSession.transitionToConnecting(); - final String runtimePath = validateRuntimePath(); + final String runtimePath = validateRuntimePath(preflightRuntime); if (runtimePath == null) { executionSession.transitionToRuntimeFailed(); publishLifecycle("Play", "Runtime preflight failed", StudioActivityEntrySeverity.ERROR, true); @@ -146,6 +150,7 @@ public final class StudioPlayStopCoordinator { streamProcessOutput(processHandle.stderr(), StudioExecutionLogSeverity.ERROR); processHandle.onExit().thenAccept(exitCode -> handleProcessExit(processHandle, exitCode)); + executionSession.transitionToConnecting(); final StudioRuntimeHandshakeResult handshake = handshakeClient.connectWithRetry( executionSession, StudioRuntimeDebugConnectionSettings.defaults(), @@ -204,12 +209,15 @@ public final class StudioPlayStopCoordinator { }); } - private String validateRuntimePath() { + private String validateRuntimePath(final boolean preflightRuntime) { final String runtimePathValue = projectSetup.prometeuRuntimePath(); if (runtimePathValue == null) { executionSession.appendRuntimeLog(StudioExecutionLogSeverity.ERROR, "Runtime preflight failed: prometeuRuntimePath is missing."); return null; } + if (!preflightRuntime) { + return runtimePathValue; + } final Path runtimePath = Path.of(runtimePathValue).resolve("prometeu").toAbsolutePath().normalize(); if (!Files.isRegularFile(runtimePath)) { executionSession.appendRuntimeLog(StudioExecutionLogSeverity.ERROR, "Runtime preflight failed: runtime not found at " + runtimePath + "."); diff --git a/prometeu-studio/src/main/java/p/studio/shipper/StudioShipperService.java b/prometeu-studio/src/main/java/p/studio/shipper/StudioShipperService.java index 97510c06..a472e795 100644 --- a/prometeu-studio/src/main/java/p/studio/shipper/StudioShipperService.java +++ b/prometeu-studio/src/main/java/p/studio/shipper/StudioShipperService.java @@ -183,6 +183,8 @@ public final class StudioShipperService { manifest.put("app_version", projectReference.version()); manifest.put("app_mode", "Game"); manifest.set("capabilities", capabilitiesNode(buildResult)); + manifest.set("asset_table", readArrayOrEmpty(projectReference.rootPath().resolve(BUILD_DIR).resolve(ASSET_TABLE_FILE))); + manifest.set("preload", readArrayOrEmpty(projectReference.rootPath().resolve(BUILD_DIR).resolve(PRELOAD_FILE))); return manifest; } diff --git a/prometeu-studio/src/test/java/p/studio/execution/StudioPlayStopCoordinatorTest.java b/prometeu-studio/src/test/java/p/studio/execution/StudioPlayStopCoordinatorTest.java index 1eb4e70a..3e0564d6 100644 --- a/prometeu-studio/src/test/java/p/studio/execution/StudioPlayStopCoordinatorTest.java +++ b/prometeu-studio/src/test/java/p/studio/execution/StudioPlayStopCoordinatorTest.java @@ -2,16 +2,14 @@ package p.studio.execution; import org.junit.jupiter.api.Test; import p.studio.StudioBackgroundTasks; -import p.studio.controls.shell.StudioActivityEntrySeverity; import p.studio.debug.runtime.StudioRuntimeDebugConnectionSettings; import p.studio.debug.runtime.StudioRuntimeHandshakeClient; import p.studio.debug.runtime.StudioRuntimeHandshakeResult; import p.studio.execution.runtime.StudioRuntimeProcessHandle; -import p.studio.execution.runtime.StudioRuntimeProcessLauncher; -import p.studio.projectstate.ProjectLocalStudioSetup; import p.studio.projects.ProjectReference; -import p.studio.shipper.StudioShipperPrepareResult; +import p.studio.projectstate.ProjectLocalStudioSetup; import p.studio.shipper.StudioShipperPreparationStatus; +import p.studio.shipper.StudioShipperPrepareResult; import p.studio.workspaces.WorkspaceId; import java.io.ByteArrayInputStream; @@ -48,7 +46,8 @@ final class StudioPlayStopCoordinatorTest { }, backgroundTasks, selectedWorkspace::set, - ignored -> { }); + ignored -> { }, + false); coordinator.play(); @@ -81,10 +80,11 @@ final class StudioPlayStopCoordinatorTest { }, backgroundTasks, selected::add, - ignored -> { }); + ignored -> { }, + false); coordinator.play(); - assertTrue(waitForState(session, StudioExecutionState.RUNNING)); + assertTrue(waitForState(session, StudioExecutionState.RUNNING), () -> "State was: " + session.snapshot().state() + " Logs: " + session.snapshot().logs()); coordinator.play(); assertEquals(1, launches.get()); @@ -119,7 +119,8 @@ final class StudioPlayStopCoordinatorTest { (projectReference, runtimePath) -> new FakeRuntimeProcessHandle(), backgroundTasks, ignored -> { }, - ignored -> { }); + ignored -> { }, + false); coordinator.play(); assertTrue(started.await(2, TimeUnit.SECONDS)); @@ -146,15 +147,16 @@ final class StudioPlayStopCoordinatorTest { session, (project, sink) -> new StudioShipperPrepareResult(StudioShipperPreparationStatus.SUCCESS, List.of(), null, null, null, null), new RecordingHandshakeClient(), - (projectReference, runtimePath) -> new FakeRuntimeProcessHandle(), + (projectReference, runtimePath) -> { throw new java.io.IOException("mock spawn failure"); }, backgroundTasks, ignored -> { }, - ignored -> { }); + ignored -> { }, + false); coordinator.play(); assertTrue(waitForState(session, StudioExecutionState.RUNTIME_FAILED)); - assertTrue(session.snapshot().logs().stream().anyMatch(entry -> entry.message().contains("Runtime preflight failed"))); + assertTrue(session.snapshot().logs().stream().anyMatch(entry -> entry.message().contains("Runtime preflight failed")), () -> "Logs: " + session.snapshot().logs()); } finally { backgroundTasks.shutdown(); } diff --git a/prometeu-studio/src/test/java/p/studio/workspaces/editor/EditorDocumentHighlightingRouterTest.java b/prometeu-studio/src/test/java/p/studio/workspaces/editor/EditorDocumentHighlightingRouterTest.java index fd9a563e..26b9d405 100644 --- a/prometeu-studio/src/test/java/p/studio/workspaces/editor/EditorDocumentHighlightingRouterTest.java +++ b/prometeu-studio/src/test/java/p/studio/workspaces/editor/EditorDocumentHighlightingRouterTest.java @@ -33,10 +33,12 @@ final class EditorDocumentHighlightingRouterTest { final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult( new LspSessionStateDTO(true, List.of("highlight")), new LspSemanticPresentationDTO( - List.of("pbs-keyword"), + List.of("pbs-keyword", "pbs-function"), List.of("/themes/pbs/semantic-highlighting.css")), List.of(), - List.of(new LspHighlightSpanDTO(new LspRangeDTO(0, 2), "pbs-keyword")), + List.of( + new LspHighlightSpanDTO(new LspRangeDTO(0, 2), "pbs-keyword"), + new LspHighlightSpanDTO(new LspRangeDTO(3, 7), "pbs-function")), List.of(), List.of(), List.of(), @@ -101,10 +103,12 @@ final class EditorDocumentHighlightingRouterTest { final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult( new LspSessionStateDTO(true, List.of("highlight")), new LspSemanticPresentationDTO( - List.of("pbs-keyword"), + List.of("pbs-keyword", "pbs-function"), List.of("/themes/pbs/missing.css")), List.of(), - List.of(new LspHighlightSpanDTO(new LspRangeDTO(0, 2), "pbs-keyword")), + List.of( + new LspHighlightSpanDTO(new LspRangeDTO(0, 2), "pbs-keyword"), + new LspHighlightSpanDTO(new LspRangeDTO(3, 7), "pbs-function")), List.of(), List.of(), List.of(), @@ -172,10 +176,13 @@ final class EditorDocumentHighlightingRouterTest { final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult( new LspSessionStateDTO(true, List.of("highlight")), new LspSemanticPresentationDTO( - List.of("pbs-service"), + List.of("pbs-keyword", "pbs-service", "pbs-function"), List.of("/themes/pbs/semantic-highlighting.css")), List.of(), - List.of(new LspHighlightSpanDTO(new LspRangeDTO(19, 23), "pbs-service")), + List.of( + new LspHighlightSpanDTO(new LspRangeDTO(0, 2), "pbs-keyword"), + new LspHighlightSpanDTO(new LspRangeDTO(3, 7), "pbs-function"), + new LspHighlightSpanDTO(new LspRangeDTO(19, 23), "pbs-service")), List.of(), List.of(), List.of(),