Harden macos runner cleanup
Some checks failed
Build Apple / Build App (macOS) (push) Waiting to run
Build Apple / Build App (iOS Simulator) (push) Has started running
Build Site / Next.js Build (push) Successful in 2m1s
Build Rust / Cargo Test (push) Has been cancelled

This commit is contained in:
Conrad Kramer 2026-03-19 14:01:37 -07:00
parent fc79766a31
commit 283209d364
5 changed files with 239 additions and 113 deletions

View file

@ -1,47 +1,33 @@
package nsc
import (
"errors"
"testing"
)
import "testing"
func TestNSCSSHBootstrapLikelySucceeded(t *testing.T) {
func TestNormalizeMacOSNSCMachineTypeRoundsUp(t *testing.T) {
t.Parallel()
err := errors.New("wait: remote command exited without exit status or exit signal")
output := `
level=info msg="Runner registered successfully."
time="2026-03-19T11:29:49Z" level=info msg="Starting job"
time="2026-03-19T11:29:50Z" level=info msg="task 124 repo is hackclub/burrow"
`
if !nscSSHBootstrapLikelySucceeded(err, output) {
t.Fatal("expected handoff success heuristic to match")
got, changed, err := normalizeMacOSNSCMachineType("5x10")
if err != nil {
t.Fatalf("normalizeMacOSNSCMachineType: %v", err)
}
if !changed {
t.Fatal("expected machine type to be normalized")
}
if got != "6x14" {
t.Fatalf("expected 6x14, got %q", got)
}
}
func TestNSCSSHBootstrapLikelySucceededRejectsIncompleteOutput(t *testing.T) {
func TestNormalizeMacOSNSCMachineTypeKeepsAllowedShape(t *testing.T) {
t.Parallel()
err := errors.New("wait: remote command exited without exit status or exit signal")
output := `level=info msg="Runner registered successfully."`
if nscSSHBootstrapLikelySucceeded(err, output) {
t.Fatal("expected incomplete runner output to remain a failure")
}
}
func TestNSCSSHBootstrapLikelySucceededRejectsDifferentErrors(t *testing.T) {
t.Parallel()
err := errors.New("exit status 1")
output := `
level=info msg="Runner registered successfully."
time="2026-03-19T11:29:49Z" level=info msg="Starting job"
time="2026-03-19T11:29:50Z" level=info msg="task 124 repo is hackclub/burrow"
`
if nscSSHBootstrapLikelySucceeded(err, output) {
t.Fatal("expected unrelated nsc ssh errors to remain failures")
got, changed, err := normalizeMacOSNSCMachineType("6x14")
if err != nil {
t.Fatalf("normalizeMacOSNSCMachineType: %v", err)
}
if changed {
t.Fatal("expected allowed machine type to remain unchanged")
}
if got != "6x14" {
t.Fatalf("expected 6x14, got %q", got)
}
}