test: keep the scripted-toolchain scenarios off windows

The four retry scenarios are driven through a scripted `go` (a POSIX shell script
placed first on PATH) and a PATH with a symlinked git. On Windows neither
harness resolves: the file would not be found through LookPath and would not
execute, and the symlink needs privileges - the tests would either fail or
silently assert nothing. They now skip there with the reason named, instead of
reporting a platform they cannot speak for. `GOOS=windows go vet ./internal/update`
compiles clean; macOS runs them for real.
This commit is contained in:
Sycun committed 2026-10-08 16:18:21 +08:00
1 parent 81bd5f1a6e
commit e8df681d9b
1 file changed
+12
+12
View File
@@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
)
@@ -20,6 +21,12 @@ type fakeGo struct {
func scriptFakeGo(t *testing.T) *fakeGo {
t.Helper()
if runtime.GOOS == "windows" {
// The scripted toolchain is a POSIX shell script: Windows would not execute it,
// LookPath would not even find it, and the scenario would silently assert
// nothing. Driving it there needs a different harness, not a different promise.
t.Skip("the scripted go toolchain needs a POSIX shell")
}
dir := t.TempDir()
marker := filepath.Join(dir, "fail-build")
f := &fakeGo{marker: marker}
@@ -58,6 +65,11 @@ func (f *fakeGo) succeed(t *testing.T) {
// (git) reachable: a directory holding a symlink to the real git and nothing else.
func hideToolchain(t *testing.T) {
t.Helper()
if runtime.GOOS == "windows" {
// Same reason as scriptFakeGo: symlinks need privileges there and the bare-name
// file would not resolve through LookPath.
t.Skip("PATH surgery here needs POSIX symlinks")
}
realGit, err := exec.LookPath("git")
if err != nil {
t.Skip("git not installed")