(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestAstGrepScanner(t *testing.T) { |
| 41 | scanner, err := NewAstGrepScanner() |
| 42 | if err != nil { |
| 43 | t.Fatalf("Failed to create scanner: %v", err) |
| 44 | } |
| 45 | defer scanner.Close() |
| 46 | |
| 47 | if !scanner.Available() { |
| 48 | t.Skip("sg not available") |
| 49 | } |
| 50 | |
| 51 | // Test on codemap's own codebase |
| 52 | results, err := scanner.ScanDirectory("..") |
| 53 | if err != nil { |
| 54 | t.Fatalf("ScanDirectory failed: %v", err) |
| 55 | } |
| 56 | |
| 57 | if len(results) == 0 { |
| 58 | t.Error("Expected some results") |
| 59 | } |
| 60 | |
| 61 | var totalFuncs, totalImports int |
| 62 | for _, r := range results { |
| 63 | totalFuncs += len(r.Functions) |
| 64 | totalImports += len(r.Imports) |
| 65 | } |
| 66 | |
| 67 | t.Logf("Scanned %d files, found %d functions and %d imports", len(results), totalFuncs, totalImports) |
| 68 | |
| 69 | // Should find some Go functions |
| 70 | if totalFuncs == 0 { |
| 71 | t.Error("Expected to find some functions") |
| 72 | } |
| 73 | } |
nothing calls this directly
no test coverage detected