feature/featuretags: skip TestAllOmitBuildTagsDeclared when not in a git repo

This test was failing on Alpine's CI which had 'git' but wasn't in a git repo:

https://github.com/tailscale/tailscale/commit/036b6a12621306da8368b167deb9858d4a8d6ce9#commitcomment-180001647

Updates #12614

Change-Id: Ic1b8856aaf020788a2a57e48738851e13ea85a93
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2026-03-19 16:00:19 +00:00
committed by Brad Fitzpatrick
parent 0d8d3831b9
commit ac19bd5e7a
+7 -10
View File
@@ -5,9 +5,7 @@ package featuretags
import ( import (
"maps" "maps"
"os"
"os/exec" "os/exec"
"path/filepath"
"regexp" "regexp"
"slices" "slices"
"strings" "strings"
@@ -91,19 +89,18 @@ func TestRequiredBy(t *testing.T) {
// Verify that all "ts_omit_foo" build tags are declared in featuretags.go // Verify that all "ts_omit_foo" build tags are declared in featuretags.go
func TestAllOmitBuildTagsDeclared(t *testing.T) { func TestAllOmitBuildTagsDeclared(t *testing.T) {
dir, err := os.Getwd() if _, err := exec.LookPath("git"); err != nil {
if err != nil { t.Skipf("git not found in PATH; skipping test")
t.Fatal(err) }
root, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
if err != nil {
t.Skipf("not in a git repository; skipping test")
} }
root := filepath.Join(dir, "..", "..")
cmd := exec.Command("git", "grep", "ts_omit_") cmd := exec.Command("git", "grep", "ts_omit_")
cmd.Dir = root cmd.Dir = strings.TrimSpace(string(root))
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
if _, err := exec.LookPath("git"); err != nil {
t.Skipf("git not found in PATH; skipping test")
}
t.Fatalf("git grep failed: %v\nOutput:\n%s", err, out) t.Fatalf("git grep failed: %v\nOutput:\n%s", err, out)
} }
rx := regexp.MustCompile(`\bts_omit_[\w_]+\b`) rx := regexp.MustCompile(`\bts_omit_[\w_]+\b`)