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 StudioBackgroundTasks backgroundTasks;
private final Consumer<WorkspaceId> workspaceSelector; private final Consumer<WorkspaceId> workspaceSelector;
private final Consumer<StudioExecutionLifecycleEvent> lifecyclePublisher; private final Consumer<StudioExecutionLifecycleEvent> lifecyclePublisher;
private final boolean preflightRuntime;
private StudioRuntimeProcessHandle activeProcess; private StudioRuntimeProcessHandle activeProcess;
private boolean stopRequested; private boolean stopRequested;
@ -48,12 +49,13 @@ public final class StudioPlayStopCoordinator {
projectReference, projectReference,
projectSetup, projectSetup,
executionSession, executionSession,
new StudioShipperService()::prepare, (project, sink) -> new StudioShipperService().prepare(project, sink),
new p.studio.debug.runtime.StudioRuntimeHandshakeService(), new p.studio.debug.runtime.StudioRuntimeHandshakeService(),
new StudioExternalRuntimeProcessLauncher(), new StudioExternalRuntimeProcessLauncher(),
Container.backgroundTasks(), Container.backgroundTasks(),
workspaceSelector, workspaceSelector,
event -> Container.eventBus().publish(event)); event -> Container.eventBus().publish(event),
true);
} }
StudioPlayStopCoordinator( StudioPlayStopCoordinator(
@ -65,7 +67,8 @@ public final class StudioPlayStopCoordinator {
final StudioRuntimeProcessLauncher runtimeProcessLauncher, final StudioRuntimeProcessLauncher runtimeProcessLauncher,
final StudioBackgroundTasks backgroundTasks, final StudioBackgroundTasks backgroundTasks,
final Consumer<WorkspaceId> workspaceSelector, final Consumer<WorkspaceId> workspaceSelector,
final Consumer<StudioExecutionLifecycleEvent> lifecyclePublisher) { final Consumer<StudioExecutionLifecycleEvent> lifecyclePublisher,
final boolean preflightRuntime) {
this.projectReference = Objects.requireNonNull(projectReference, "projectReference"); this.projectReference = Objects.requireNonNull(projectReference, "projectReference");
this.projectSetup = Objects.requireNonNull(projectSetup, "projectSetup"); this.projectSetup = Objects.requireNonNull(projectSetup, "projectSetup");
this.executionSession = Objects.requireNonNull(executionSession, "executionSession"); this.executionSession = Objects.requireNonNull(executionSession, "executionSession");
@ -75,6 +78,7 @@ public final class StudioPlayStopCoordinator {
this.backgroundTasks = Objects.requireNonNull(backgroundTasks, "backgroundTasks"); this.backgroundTasks = Objects.requireNonNull(backgroundTasks, "backgroundTasks");
this.workspaceSelector = Objects.requireNonNull(workspaceSelector, "workspaceSelector"); this.workspaceSelector = Objects.requireNonNull(workspaceSelector, "workspaceSelector");
this.lifecyclePublisher = Objects.requireNonNull(lifecyclePublisher, "lifecyclePublisher"); this.lifecyclePublisher = Objects.requireNonNull(lifecyclePublisher, "lifecyclePublisher");
this.preflightRuntime = preflightRuntime;
} }
public void play() { public void play() {
@ -121,7 +125,7 @@ public final class StudioPlayStopCoordinator {
} }
executionSession.transitionToConnecting(); executionSession.transitionToConnecting();
final String runtimePath = validateRuntimePath(); final String runtimePath = validateRuntimePath(preflightRuntime);
if (runtimePath == null) { if (runtimePath == null) {
executionSession.transitionToRuntimeFailed(); executionSession.transitionToRuntimeFailed();
publishLifecycle("Play", "Runtime preflight failed", StudioActivityEntrySeverity.ERROR, true); publishLifecycle("Play", "Runtime preflight failed", StudioActivityEntrySeverity.ERROR, true);
@ -146,6 +150,7 @@ public final class StudioPlayStopCoordinator {
streamProcessOutput(processHandle.stderr(), StudioExecutionLogSeverity.ERROR); streamProcessOutput(processHandle.stderr(), StudioExecutionLogSeverity.ERROR);
processHandle.onExit().thenAccept(exitCode -> handleProcessExit(processHandle, exitCode)); processHandle.onExit().thenAccept(exitCode -> handleProcessExit(processHandle, exitCode));
executionSession.transitionToConnecting();
final StudioRuntimeHandshakeResult handshake = handshakeClient.connectWithRetry( final StudioRuntimeHandshakeResult handshake = handshakeClient.connectWithRetry(
executionSession, executionSession,
StudioRuntimeDebugConnectionSettings.defaults(), StudioRuntimeDebugConnectionSettings.defaults(),
@ -204,12 +209,15 @@ public final class StudioPlayStopCoordinator {
}); });
} }
private String validateRuntimePath() { private String validateRuntimePath(final boolean preflightRuntime) {
final String runtimePathValue = projectSetup.prometeuRuntimePath(); final String runtimePathValue = projectSetup.prometeuRuntimePath();
if (runtimePathValue == null) { if (runtimePathValue == null) {
executionSession.appendRuntimeLog(StudioExecutionLogSeverity.ERROR, "Runtime preflight failed: prometeuRuntimePath is missing."); executionSession.appendRuntimeLog(StudioExecutionLogSeverity.ERROR, "Runtime preflight failed: prometeuRuntimePath is missing.");
return null; return null;
} }
if (!preflightRuntime) {
return runtimePathValue;
}
final Path runtimePath = Path.of(runtimePathValue).resolve("prometeu").toAbsolutePath().normalize(); final Path runtimePath = Path.of(runtimePathValue).resolve("prometeu").toAbsolutePath().normalize();
if (!Files.isRegularFile(runtimePath)) { if (!Files.isRegularFile(runtimePath)) {
executionSession.appendRuntimeLog(StudioExecutionLogSeverity.ERROR, "Runtime preflight failed: runtime not found at " + 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_version", projectReference.version());
manifest.put("app_mode", "Game"); manifest.put("app_mode", "Game");
manifest.set("capabilities", capabilitiesNode(buildResult)); 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; return manifest;
} }

View File

@ -2,16 +2,14 @@ package p.studio.execution;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import p.studio.StudioBackgroundTasks; import p.studio.StudioBackgroundTasks;
import p.studio.controls.shell.StudioActivityEntrySeverity;
import p.studio.debug.runtime.StudioRuntimeDebugConnectionSettings; import p.studio.debug.runtime.StudioRuntimeDebugConnectionSettings;
import p.studio.debug.runtime.StudioRuntimeHandshakeClient; import p.studio.debug.runtime.StudioRuntimeHandshakeClient;
import p.studio.debug.runtime.StudioRuntimeHandshakeResult; import p.studio.debug.runtime.StudioRuntimeHandshakeResult;
import p.studio.execution.runtime.StudioRuntimeProcessHandle; 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.projects.ProjectReference;
import p.studio.shipper.StudioShipperPrepareResult; import p.studio.projectstate.ProjectLocalStudioSetup;
import p.studio.shipper.StudioShipperPreparationStatus; import p.studio.shipper.StudioShipperPreparationStatus;
import p.studio.shipper.StudioShipperPrepareResult;
import p.studio.workspaces.WorkspaceId; import p.studio.workspaces.WorkspaceId;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -48,7 +46,8 @@ final class StudioPlayStopCoordinatorTest {
}, },
backgroundTasks, backgroundTasks,
selectedWorkspace::set, selectedWorkspace::set,
ignored -> { }); ignored -> { },
false);
coordinator.play(); coordinator.play();
@ -81,10 +80,11 @@ final class StudioPlayStopCoordinatorTest {
}, },
backgroundTasks, backgroundTasks,
selected::add, selected::add,
ignored -> { }); ignored -> { },
false);
coordinator.play(); coordinator.play();
assertTrue(waitForState(session, StudioExecutionState.RUNNING)); assertTrue(waitForState(session, StudioExecutionState.RUNNING), () -> "State was: " + session.snapshot().state() + " Logs: " + session.snapshot().logs());
coordinator.play(); coordinator.play();
assertEquals(1, launches.get()); assertEquals(1, launches.get());
@ -119,7 +119,8 @@ final class StudioPlayStopCoordinatorTest {
(projectReference, runtimePath) -> new FakeRuntimeProcessHandle(), (projectReference, runtimePath) -> new FakeRuntimeProcessHandle(),
backgroundTasks, backgroundTasks,
ignored -> { }, ignored -> { },
ignored -> { }); ignored -> { },
false);
coordinator.play(); coordinator.play();
assertTrue(started.await(2, TimeUnit.SECONDS)); assertTrue(started.await(2, TimeUnit.SECONDS));
@ -146,15 +147,16 @@ final class StudioPlayStopCoordinatorTest {
session, session,
(project, sink) -> new StudioShipperPrepareResult(StudioShipperPreparationStatus.SUCCESS, List.of(), null, null, null, null), (project, sink) -> new StudioShipperPrepareResult(StudioShipperPreparationStatus.SUCCESS, List.of(), null, null, null, null),
new RecordingHandshakeClient(), new RecordingHandshakeClient(),
(projectReference, runtimePath) -> new FakeRuntimeProcessHandle(), (projectReference, runtimePath) -> { throw new java.io.IOException("mock spawn failure"); },
backgroundTasks, backgroundTasks,
ignored -> { }, ignored -> { },
ignored -> { }); ignored -> { },
false);
coordinator.play(); coordinator.play();
assertTrue(waitForState(session, StudioExecutionState.RUNTIME_FAILED)); 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 { } finally {
backgroundTasks.shutdown(); backgroundTasks.shutdown();
} }

View File

@ -33,10 +33,12 @@ final class EditorDocumentHighlightingRouterTest {
final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult( final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult(
new LspSessionStateDTO(true, List.of("highlight")), new LspSessionStateDTO(true, List.of("highlight")),
new LspSemanticPresentationDTO( new LspSemanticPresentationDTO(
List.of("pbs-keyword"), List.of("pbs-keyword", "pbs-function"),
List.of("/themes/pbs/semantic-highlighting.css")), List.of("/themes/pbs/semantic-highlighting.css")),
List.of(), 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(), List.of(),
List.of(), List.of(),
@ -101,10 +103,12 @@ final class EditorDocumentHighlightingRouterTest {
final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult( final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult(
new LspSessionStateDTO(true, List.of("highlight")), new LspSessionStateDTO(true, List.of("highlight")),
new LspSemanticPresentationDTO( new LspSemanticPresentationDTO(
List.of("pbs-keyword"), List.of("pbs-keyword", "pbs-function"),
List.of("/themes/pbs/missing.css")), List.of("/themes/pbs/missing.css")),
List.of(), 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(), List.of(),
List.of(), List.of(),
@ -172,10 +176,13 @@ final class EditorDocumentHighlightingRouterTest {
final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult( final LspAnalyzeDocumentResult analysis = new LspAnalyzeDocumentResult(
new LspSessionStateDTO(true, List.of("highlight")), new LspSessionStateDTO(true, List.of("highlight")),
new LspSemanticPresentationDTO( new LspSemanticPresentationDTO(
List.of("pbs-service"), List.of("pbs-keyword", "pbs-service", "pbs-function"),
List.of("/themes/pbs/semantic-highlighting.css")), List.of("/themes/pbs/semantic-highlighting.css")),
List.of(), 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(), List.of(),
List.of(), List.of(),