test(11.1-06): branch-level tests for every docsite stage (94.8% coverage)

- load, render, emit, snippet, highlight, serve and checker branch tests;
  docs:build --check, docs:sync and docs:serve output tests in cmd/summer
- fix: a CRLF or BOM page is reported as such, not as a page without a
  frontmatter block (TestFrontmatterEncodingProblems)
- fix: src=#Type.Method finds a method with a parenthesised receiver
  (TestSnippetGenericsAndGroups, Box.Paren)
- fix: docs:serve adds its watches before announcing the server, so an
  edit made right after the serving line rebuilds (TestServeWatchRebuilds)
This commit is contained in:
Jakub Zych
2026-10-01 00:05:12 +02:00
parent 1d38e73f03
commit 28afd4d197
13 changed files with 2276 additions and 11 deletions

View File

@@ -293,3 +293,34 @@ func TestServeRefusesNonLoopback(t *testing.T) {
}
}
}
// TestThemeAssetsAndPager checks the full asset set every build ships and
// the pager edge that points back at the index page.
func TestThemeAssetsAndPager(t *testing.T) {
out := buildTheme(t)
for _, name := range []string{
"assets/site.css", "assets/site.js", "assets/search.js", "assets/theme-init.js",
"assets/LICENSE-lucide.txt", "assets/fonts/LICENSE-dm-sans.txt", "assets/fonts/LICENSE-dm-mono.txt",
"assets/fonts/dm-sans-latin-400-normal.woff2", "assets/fonts/dm-sans-latin-600-normal.woff2",
"assets/fonts/dm-sans-latin-ext-400-normal.woff2", "assets/fonts/dm-sans-latin-ext-600-normal.woff2",
"assets/fonts/dm-sans-latin-400-italic.woff2", "assets/fonts/dm-sans-latin-ext-400-italic.woff2",
"assets/fonts/dm-mono-latin-400-normal.woff2", "assets/fonts/dm-mono-latin-ext-400-normal.woff2",
MarkerFile,
} {
if st, err := os.Stat(filepath.Join(out, name)); err != nil || st.Size() == 0 {
t.Errorf("missing or empty %s: %v", name, err)
}
}
// setup/start's Previous is the index page: no section line.
start := readOut(t, out, "setup/start.html")
prev := start[strings.Index(start, "pager-prev"):]
prev = prev[:strings.Index(prev, "</a>")]
if strings.Contains(prev, "pager-section") || !strings.Contains(prev, "Acme docs") {
t.Errorf("pager back to the index = %q", prev)
}
for _, name := range []string{"index.html", "setup/start.html"} {
if html := readOut(t, out, name); !strings.Contains(html, `<title>`) || strings.Count(html, "<h1") != 1 {
t.Errorf("%s must have a title and exactly one H1", name)
}
}
}