fix(test): skip Linux-only hosts-file tests on non-Linux CI runners
v2.1.2's release CI failed on the Windows build leg: TestApplyHostsOverride_* call applyHostsOverride(), which correctly refuses unconditionally on non-Linux (hosts_override.go) -- but the tests didn't account for `go test ./...` running on every platform the CI matrix builds for, only Linux. Skip them on non-Linux with a clear reason instead.
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -11,6 +12,14 @@ import (
|
|||||||
|
|
||||||
func withTempHostsFile(t *testing.T, initial string) string {
|
func withTempHostsFile(t *testing.T, initial string) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
// applyHostsOverride refuses unconditionally on non-Linux (see
|
||||||
|
// hosts_override.go) -- these tests exercise the Linux write path
|
||||||
|
// specifically, so they'd fail for the right reason on the Windows CI
|
||||||
|
// runner if not skipped. Confirmed the hard way: a real CI run failed
|
||||||
|
// here after this was missed.
|
||||||
|
if runtime.GOOS != "linux" {
|
||||||
|
t.Skip("applyHostsOverride is Linux-only; skipping on " + runtime.GOOS)
|
||||||
|
}
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
path := filepath.Join(dir, "hosts")
|
path := filepath.Join(dir, "hosts")
|
||||||
if initial != "" {
|
if initial != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user