diff --git a/scripts/smoke-cli-recovery-readiness.go b/scripts/smoke-cli-recovery-readiness.go index d805fb412..21de34875 100644 --- a/scripts/smoke-cli-recovery-readiness.go +++ b/scripts/smoke-cli-recovery-readiness.go @@ -17,6 +17,7 @@ import ( const ( stateRelativePath = "Temp/UnityCliLoop/server-state.json" + projectRunnerPinPath = ".uloop/project-runner-pin.json" expectedDynamicCodeResult = "cli-recovery-readiness-e2e" e2eDynamicCode = `return "cli-recovery-readiness-e2e";` timeoutExitCode = 124 @@ -61,7 +62,7 @@ func run() error { if err := runLiveRecoverySequence(opts); err != nil { return err } - if err := runStaleRecoveryStateIgnoredSequence(opts.uloopPath, opts.timeout); err != nil { + if err := runStaleRecoveryStateIgnoredSequence(opts.uloopPath, opts.projectPath, opts.timeout); err != nil { return err } @@ -211,7 +212,7 @@ func runLiveRecoverySequence(opts options) error { return assertDynamicCodeResult(dynamicPayload) } -func runStaleRecoveryStateIgnoredSequence(uloopPath string, timeout time.Duration) error { +func runStaleRecoveryStateIgnoredSequence(uloopPath string, sourceProjectPath string, timeout time.Duration) error { projectPath, err := os.MkdirTemp("", "uloop-stale-state-") if err != nil { return err @@ -221,6 +222,10 @@ func runStaleRecoveryStateIgnoredSequence(uloopPath string, timeout time.Duratio if err := createMinimalUnityProject(projectPath); err != nil { return err } + // Why: the dispatcher requires the runner pin before this sequence can reach the connection failure assertion. + if err := copyProjectRunnerPin(sourceProjectPath, projectPath); err != nil { + return err + } if err := writeStaleServerState(projectPath); err != nil { return err } @@ -244,6 +249,20 @@ func runStaleRecoveryStateIgnoredSequence(uloopPath string, timeout time.Duratio return nil } +func copyProjectRunnerPin(sourceProjectPath string, targetProjectPath string) error { + sourcePath := filepath.Join(sourceProjectPath, filepath.FromSlash(projectRunnerPinPath)) + data, err := os.ReadFile(sourcePath) + if err != nil { + return err + } + + targetPath := filepath.Join(targetProjectPath, filepath.FromSlash(projectRunnerPinPath)) + if err := os.MkdirAll(filepath.Dir(targetPath), 0o755); err != nil { + return err + } + return os.WriteFile(targetPath, data, 0o644) +} + func runUloop(uloopPath string, projectPath string, args []string, timeout time.Duration) commandResult { return runUloopWithEnv(uloopPath, projectPath, args, timeout, nil) } diff --git a/scripts/test-smoke-cli-recovery-readiness.sh b/scripts/test-smoke-cli-recovery-readiness.sh index d7adab044..c90f6adb2 100755 --- a/scripts/test-smoke-cli-recovery-readiness.sh +++ b/scripts/test-smoke-cli-recovery-readiness.sh @@ -22,6 +22,8 @@ cleanup() { trap cleanup EXIT INT TERM mkdir -p "$PROJECT_PATH/Assets" "$PROJECT_PATH/ProjectSettings" +mkdir -p "$PROJECT_PATH/.uloop" +cp "$ROOT_DIR/.uloop/project-runner-pin.json" "$PROJECT_PATH/.uloop/project-runner-pin.json" cat > "$FAKE_ULOOP_SOURCE" <<'EOF' package main