package httpd import ( "io/fs" "regexp" "strings" "testing" ) // A reader has no copy of the book, so nothing that cites it belongs on a page they can open. var bookTalk = regexp.MustCompile(`(?i)\b(chapter|appendix|rule) \d|BOOK\.md|BUILD\.md|SPEC-NOTES`) func TestNoPageTalksToWhoeverWroteIt(t *testing.T) { names, err := fs.Glob(templateFS, "templates/*.html") if err != nil || len(names) == 0 { t.Fatalf("found no templates to read: %v", err) } for _, name := range names { body, err := fs.ReadFile(templateFS, name) if err != nil { t.Fatal(err) } for i, line := range strings.Split(string(body), "\n") { // A go comment is for whoever writes barerepo, and a template has no comments to skip. if found := bookTalk.FindString(line); found != "" { t.Errorf("%s:%d shows a reader %q, and a reader has no book", name, i+1, found) } } } }