test(ci): skip chmod-dependent tests when running as root
ci / vet, staticcheck, test, build (push) Failing after 2m54s

Docker CI containers run as root by default (golang:1.26-alpine), where
os.Chmod has no effect and permission restrictions don't apply. Four
tests were failing because they relied on chmod to force error paths:

- gradle: TestWriteVersionReadOnly
- cmd:    TestInitConfigWriteFails, TestRunLatestTagFails
- gitutil: TestLatestTagTagsIterFails (had broken skip logic that only
  fired if Chmod itself errored, which never happens as root)

Replace all four with an upfront os.Getuid() == 0 check so they are
skipped cleanly in root environments and still run (and must pass) on
non-root local development.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 21:10:41 +02:00
parent dfdf2b019a
commit a4cd00cc4d
3 changed files with 15 additions and 7 deletions
+6
View File
@@ -852,6 +852,9 @@ func TestPrintVerboseConfigDirect(t *testing.T) {
// ── initConfig coverage ───────────────────────────────────────────────────────
func TestInitConfigWriteFails(t *testing.T) {
if os.Getuid() == 0 {
t.Skip("skipping: chmod restrictions do not apply when running as root")
}
dir := t.TempDir()
os.Chmod(dir, 0555)
defer os.Chmod(dir, 0755)
@@ -904,6 +907,9 @@ func TestRunWorkingTreeCheckFails(t *testing.T) {
}
func TestRunLatestTagFails(t *testing.T) {
if os.Getuid() == 0 {
t.Skip("skipping: chmod restrictions do not apply when running as root")
}
_, dir := setupRepo(t)
addFile(t, dir, "x.go", "// fix")
repo, _ := gogit.PlainOpen(dir)