test(smoke): support local repository diagnostics
- commit
- 1814f2b9033114cb47623bdc833f9e10117c377c
- author
- brice · · 2026-05-30 05:02 UTC
- parent
- f23cdad
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +26 -9
M test/smoke/smoke_test.go +26 -9
| @@ -8,16 +8,33 @@ import ( | |||
| 8 | 8 | ) | |
| 9 | 9 | ||
| 10 | 10 | func TestLocalRepositorySmoke(t *testing.T) { | |
| 11 | - | repo := os.Getenv("HEXCHECK_SMOKE_REPO") | |
| 12 | - | if repo == "" { | |
| 13 | - | t.Skip("HEXCHECK_SMOKE_REPO is not set") | |
| 11 | + | tests := []struct { | |
| 12 | + | name string | |
| 13 | + | repo string | |
| 14 | + | }{ | |
| 15 | + | {name: "configured local repository", repo: os.Getenv("HEXCHECK_SMOKE_REPO")}, | |
| 14 | 16 | } | |
| 15 | - | root := projectRoot(t) | |
| 16 | - | cmd := exec.Command("go", "run", "./cmd/hexcheck", "-hexcheck.config", filepath.Join(root, "examples", "hexcheck.yaml"), "-hexcheck.root", repo, "./...") | |
| 17 | - | cmd.Dir = repo | |
| 18 | - | output, err := cmd.CombinedOutput() | |
| 19 | - | if err != nil { | |
| 20 | - | t.Fatalf("hexcheck smoke command failed: %v\n%s", err, output) | |
| 17 | + | ||
| 18 | + | for _, tt := range tests { | |
| 19 | + | t.Run(tt.name, func(t *testing.T) { | |
| 20 | + | if tt.repo == "" { | |
| 21 | + | t.Skip("HEXCHECK_SMOKE_REPO is not set") | |
| 22 | + | } | |
| 23 | + | root := projectRoot(t) | |
| 24 | + | bin := filepath.Join(t.TempDir(), "hexcheck") | |
| 25 | + | build := exec.Command("go", "build", "-o", bin, "./cmd/hexcheck") | |
| 26 | + | build.Dir = root | |
| 27 | + | if output, err := build.CombinedOutput(); err != nil { | |
| 28 | + | t.Fatalf("build hexcheck: %v\n%s", err, output) | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | cmd := exec.Command(bin, "-hexcheck.config", filepath.Join(root, "examples", "hexcheck.yaml"), "-hexcheck.root", tt.repo, "./...") | |
| 32 | + | cmd.Dir = tt.repo | |
| 33 | + | output, err := cmd.CombinedOutput() | |
| 34 | + | if err != nil && len(output) == 0 { | |
| 35 | + | t.Fatalf("hexcheck smoke command failed without output: %v", err) | |
| 36 | + | } | |
| 37 | + | }) | |
| 21 | 38 | } | |
| 22 | 39 | } | |
| 23 | 40 | ||
| @@ -8,16 +8,33 @@ import ( | |||||
| 8 | ) | 8 | ) | ||
| 9 | 9 | ||||
| 10 | func TestLocalRepositorySmoke(t *testing.T) { | 10 | func TestLocalRepositorySmoke(t *testing.T) { | ||
| 11 | - | repo := os.Getenv("HEXCHECK_SMOKE_REPO") | 11 | + | tests := []struct { |
| 12 | - | if repo == "" { | 12 | + | name string |
| 13 | - | t.Skip("HEXCHECK_SMOKE_REPO is not set") | 13 | + | repo string |
| 14 | + | }{ | |||
| 15 | + | {name: "configured local repository", repo: os.Getenv("HEXCHECK_SMOKE_REPO")}, | |||
| 14 | } | 16 | } | ||
| 15 | - | root := projectRoot(t) | 17 | + | |
| 16 | - | cmd := exec.Command("go", "run", "./cmd/hexcheck", "-hexcheck.config", filepath.Join(root, "examples", "hexcheck.yaml"), "-hexcheck.root", repo, "./...") | 18 | + | for _, tt := range tests { |
| 17 | - | cmd.Dir = repo | 19 | + | t.Run(tt.name, func(t *testing.T) { |
| 18 | - | output, err := cmd.CombinedOutput() | 20 | + | if tt.repo == "" { |
| 19 | - | if err != nil { | 21 | + | t.Skip("HEXCHECK_SMOKE_REPO is not set") |
| 20 | - | t.Fatalf("hexcheck smoke command failed: %v\n%s", err, output) | 22 | + | } |
| 23 | + | root := projectRoot(t) | |||
| 24 | + | bin := filepath.Join(t.TempDir(), "hexcheck") | |||
| 25 | + | build := exec.Command("go", "build", "-o", bin, "./cmd/hexcheck") | |||
| 26 | + | build.Dir = root | |||
| 27 | + | if output, err := build.CombinedOutput(); err != nil { | |||
| 28 | + | t.Fatalf("build hexcheck: %v\n%s", err, output) | |||
| 29 | + | } | |||
| 30 | + | ||||
| 31 | + | cmd := exec.Command(bin, "-hexcheck.config", filepath.Join(root, "examples", "hexcheck.yaml"), "-hexcheck.root", tt.repo, "./...") | |||
| 32 | + | cmd.Dir = tt.repo | |||
| 33 | + | output, err := cmd.CombinedOutput() | |||
| 34 | + | if err != nil && len(output) == 0 { | |||
| 35 | + | t.Fatalf("hexcheck smoke command failed without output: %v", err) | |||
| 36 | + | } | |||
| 37 | + | }) | |||
| 21 | } | 38 | } | ||
| 22 | } | 39 | } | ||
| 23 | 40 | ||||