Build(ctx, req) never opens FIFOs, sockets or devices (Kind=Special; U-P1-10), reads at most MaxBytes, keeps at most DirLimit directory entries and MaxLines text lines, and honours ctx in reads, tools and highlighting. pdftotext/pdfinfo/ffprobe run in their own process group with a 3 s timeout and are killed with their children. A chroma formatter writes foreground SGR only (no background, no regexp post-processing); the first HighlightLines (400) lines are highlighted, so 64 KiB of Go takes ~20 ms (was 190). Remote images are downloaded to an LRU cache only up to max_remote_image_bytes (N-P1-16); a 32-entry result cache avoids rebuilds. theme.ChromaStyle maps every built-in theme (U-P2); KindLabel fixes the inverted label (U-P2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
595 B
Go
26 lines
595 B
Go
package theme
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/alecthomas/chroma/v2/styles"
|
|
)
|
|
|
|
func TestEveryThemeHasChromaStyle(t *testing.T) {
|
|
for _, name := range Names() {
|
|
s, ok := chromaStyles[name]
|
|
if !ok {
|
|
t.Errorf("theme %q has no chroma mapping", name)
|
|
continue
|
|
}
|
|
if _, ok := styles.Registry[s]; !ok {
|
|
t.Errorf("theme %q maps to unknown chroma style %q", name, s)
|
|
}
|
|
}
|
|
if len(chromaStyles) != len(Names()) {
|
|
t.Errorf("mapping has %d entries for %d themes", len(chromaStyles), len(Names()))
|
|
}
|
|
if ChromaStyle("no-such-theme") != "catppuccin-mocha" {
|
|
t.Error("fallback")
|
|
}
|
|
}
|