Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions scripts/smoke-cli-recovery-readiness.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/test-smoke-cli-recovery-readiness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down