package manifest import ( "io/fs" "os" "path/filepath" "regexp" "strings" "testing" ) // Held by the test that calls it (§626: no new test function). No code of the watchman names its own module: its buckets, its consumer, its finding observer and its tools' names take the // module its credential (or the runtime that serves its tools) names (design 47 G A-296, §428). The manifest alone says it. func noCodeNamesTheWatchmansOwnModule(t *testing.T) { name := regexp.MustCompile(`"` + regexp.QuoteMeta(watchmanModule) + `(_[^"]*)?"`) err := filepath.WalkDir(".", func(path string, d fs.DirEntry, err error) error { if err != nil || d.IsDir() || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") { return err } src, err := os.ReadFile(path) if err != nil { return err } for i, line := range strings.Split(string(src), "\n") { if !strings.HasPrefix(strings.TrimSpace(line), "//") && name.MatchString(line) { t.Errorf("%s:%d names the watchman's own module: %s", path, i+1, strings.TrimSpace(line)) } } return nil }) if err != nil { t.Fatal(err) } }