The built-in schema now describes Ghostty 1.4.0: 212 options, the new choices of copy-on-select, window-padding-balance = equal, number limits that also take "unlimited", and categories for the new options. genschema reads Ghostty's compatibility table, so old names and values Ghostty still accepts are no longer reported as errors: a renamed key such as scrollback-limit is shown in yellow and renamed in place with enter, a replaced option names its successors, and old values such as copy-on-select = true are accepted with a note. Theme previews expand ~/ like Ghostty 1.4 and only look where Ghostty looks for user themes. Theme names with parentheses of their own keep them. A live test checks every ghostty command against the installed Ghostty. Docs and screenshots updated for 1.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
2.3 KiB
Go
89 lines
2.3 KiB
Go
package ghostty
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestLiveGhostty runs every command ghosttyconf uses against the installed
|
|
// Ghostty and checks that the output is still understood. It is meant for a
|
|
// new Ghostty release and only runs when asked for:
|
|
//
|
|
// GHOSTTYCONF_LIVE_TEST=1 go test -run Live -v ./internal/ghostty
|
|
func TestLiveGhostty(t *testing.T) {
|
|
if os.Getenv("GHOSTTYCONF_LIVE_TEST") == "" {
|
|
t.Skip("set GHOSTTYCONF_LIVE_TEST=1 to run against the installed Ghostty")
|
|
}
|
|
g, err := Find(os.Getenv("GHOSTTYCONF_GHOSTTY"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if g.Version == "" {
|
|
t.Fatal("+version: no version found")
|
|
}
|
|
t.Logf("Ghostty %s at %s", g.Version, g.Bin)
|
|
|
|
docs, err := g.DefaultsWithDocs()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, want := range []string{"\nfont-family = ", "\nkeybind = ", "\n# "} {
|
|
if !strings.Contains(docs, want) {
|
|
t.Errorf("+show-config --default --docs: no %q", want)
|
|
}
|
|
}
|
|
|
|
themes, err := g.Themes()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(themes) < 100 || !slices.Contains(themes, "Catppuccin Mocha") {
|
|
t.Errorf("+list-themes: %d themes, Catppuccin Mocha missing or too few", len(themes))
|
|
}
|
|
for _, name := range themes {
|
|
if strings.HasSuffix(name, " (resources)") || strings.HasSuffix(name, " (user)") {
|
|
t.Errorf("+list-themes: location left on %q", name)
|
|
break
|
|
}
|
|
}
|
|
th, err := g.LoadTheme("Catppuccin Mocha")
|
|
if err != nil {
|
|
t.Fatalf("theme file: %v", err)
|
|
}
|
|
if th.Background == "" || th.Palette[15] == "" {
|
|
t.Errorf("theme file: %+v", th)
|
|
}
|
|
|
|
fonts, err := g.Fonts()
|
|
if err != nil || len(fonts) == 0 {
|
|
t.Errorf("+list-fonts: %d fonts, %v", len(fonts), err)
|
|
}
|
|
|
|
actions, err := g.Actions()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
byName := map[string]Action{}
|
|
for _, a := range actions {
|
|
byName[a.Name] = a
|
|
}
|
|
if a := byName["new_split"]; len(actions) < 50 || a.Summary == "" || !strings.Contains(a.Doc, "right") {
|
|
t.Errorf("+list-actions --docs: %d actions, new_split = %+v", len(actions), a)
|
|
}
|
|
|
|
conf := filepath.Join(t.TempDir(), "config")
|
|
if err := os.WriteFile(conf, []byte("font-size = 14\nfont-size = abc\nbogus-key = 1\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
errs, err := g.Validate(conf)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(errs) != 2 || errs[0].Line != 2 || errs[1].Line != 3 {
|
|
t.Errorf("+validate-config: %v", errs)
|
|
}
|
|
}
|