//go:build browser package harness import ( "os" "os/exec" "path/filepath" "testing" ) // ChromePath finds the Chromium a browser-tagged test drives: // FIESTA_CHROME first, then the usual PATH names, then the Playwright // cache. One discovery story for every browser test. // // A skip is not a pass: with no browser this fails, unless // FIESTA_BROWSER_OPTIONAL is set, which makes the skip a deliberate // visible choice rather than an accident. func ChromePath(t *testing.T) string { t.Helper() if p := os.Getenv("FIESTA_CHROME"); p != "" { return p } for _, name := range []string{"chromium", "chromium-browser", "google-chrome", "google-chrome-stable"} { if p, err := exec.LookPath(name); err == nil { return p } } if home, err := os.UserHomeDir(); err == nil { hits, _ := filepath.Glob(filepath.Join(home, ".cache", "ms-playwright", "chromium-*", "chrome-linux64", "chrome")) if len(hits) > 0 { return hits[len(hits)-1] } } if os.Getenv("FIESTA_BROWSER_OPTIONAL") != "" { t.Skip("no chromium found, FIESTA_BROWSER_OPTIONAL set — SKIPPED, not passed") } t.Fatal("no chromium found: set FIESTA_CHROME, or FIESTA_BROWSER_OPTIONAL to skip deliberately") return "" }