(t *testing.T)
| 216 | } |
| 217 | |
| 218 | func TestScanForDepsRejectsNonAstGrepSg(t *testing.T) { |
| 219 | if runtime.GOOS == "windows" { |
| 220 | t.Skip("requires shell script execution") |
| 221 | } |
| 222 | |
| 223 | tmpDir := t.TempDir() |
| 224 | fakeBinary := filepath.Join(tmpDir, "sg") |
| 225 | if err := os.WriteFile(fakeBinary, []byte("#!/bin/sh\necho 'setgroups utility' >&2\nexit 1\n"), 0755); err != nil { |
| 226 | t.Fatalf("failed to create fake sg binary: %v", err) |
| 227 | } |
| 228 | |
| 229 | oldPath := os.Getenv("PATH") |
| 230 | if err := os.Setenv("PATH", tmpDir); err != nil { |
| 231 | t.Fatalf("failed to set PATH: %v", err) |
| 232 | } |
| 233 | t.Cleanup(func() { |
| 234 | _ = os.Setenv("PATH", oldPath) |
| 235 | }) |
| 236 | |
| 237 | _, err := ScanForDeps(t.TempDir()) |
| 238 | if !errors.Is(err, ErrAstGrepNotFound) { |
| 239 | t.Fatalf("expected ErrAstGrepNotFound, got %v", err) |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | func TestBundledAstGrepCandidates(t *testing.T) { |
| 244 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected