package mapatest import ( "go/parser" "go/token" "io/fs" "path/filepath" "strconv" "strings" "testing" ) // frozenRastrillo is rastrillo's path before it moved. Nothing after // v0.23.0 was released under it, so code importing it gets no fix, and // its own checks cannot tell (Fichas zoomed iOS on every tap that way). const frozenRastrillo = "github.com/carlosframework/rastrillo" func TestNoFrozenRastrilloImport(t *testing.T) { root, _ := filepath.Abs(filepath.Join("..", "..")) files := token.NewFileSet() checked := 0 err := filepath.WalkDir(root, func(path string, entry fs.DirEntry, err error) error { if err != nil || entry.IsDir() || !strings.HasSuffix(path, ".go") { return err } parsed, err := parser.ParseFile(files, path, nil, parser.ImportsOnly) if err != nil { return err } checked++ for _, spec := range parsed.Imports { imported, _ := strconv.Unquote(spec.Path.Value) if strings.HasPrefix(imported, frozenRastrillo) { t.Errorf("%s imports the frozen %s", path, imported) } } return nil }) if err != nil || checked == 0 { t.Fatalf("walked %d files: %v", checked, err) } }