fix tests

This commit is contained in:
bQUARKz 2026-04-07 06:06:02 +01:00
parent f251e9112e
commit 88bf9fbd45
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
4 changed files with 41 additions and 22 deletions

View File

@ -36,6 +36,7 @@ public final class StudioPlayStopCoordinator {
private final StudioBackgroundTasks backgroundTasks;
private final Consumer<WorkspaceId> workspaceSelector;
private final Consumer<StudioExecutionLifecycleEvent> 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<WorkspaceId> workspaceSelector,
final Consumer<StudioExecutionLifecycleEvent> lifecyclePublisher) {
final Consumer<StudioExecutionLifecycleEvent> 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 + ".");

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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(),