fix(test): skip TestLocalResolver_BubblesUpCopyFailure when uid==0

os.Chmod(dst, 0o555) silently passes when os.Geteuid() == 0 because
root bypasses POSIX permission checks. A previous attempt to use a
symlink to /dev/full also fails: Go's os.MkdirAll resolves the symlink
during path traversal and the kernel allows mkdir("/dev/full") as a
device-table entry — io.Copy to /dev/full then succeeds with 0 bytes
written and returns nil.

The honest, consistent fix mirrors TestLocalResolver_CopyFileSourceUnreadable:
skip when running as root. The write-failure propagation logic is
exercised correctly in non-root CI environments.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Molecule AI · core-devops 2026-05-09 22:22:44 +00:00
parent bceed5323d
commit e65633bf15

View File

@ -132,14 +132,19 @@ func TestLocalResolver_HonoursContextCancellation(t *testing.T) {
}
func TestLocalResolver_BubblesUpCopyFailure(t *testing.T) {
// Source file the copyTree walk would read; make dst unwritable so
// the copyFile step fails.
// os.Chmod(dst, 0o555) silently passes when os.Geteuid() == 0
// (root bypasses POSIX permission checks). We cannot reliably
// exercise the write-failure branch in a root environment without
// patching the syscalls, so skip it honestly.
if os.Getuid() == 0 {
t.Skip("running as root — cannot exercise write-failure branch")
}
base := t.TempDir()
writePlugin(t, base, "demo", map[string]string{
"plugin.yaml": "name: demo\n",
})
dst := t.TempDir()
// Make dst read-only so creating files inside it fails.
if err := os.Chmod(dst, 0o555); err != nil {
t.Fatal(err)
}