Files
ghosttyconf/tools/genschema/main_test.go
T
mikeandClaude Opus 5.5 df261910c5 Support Ghostty 1.4, version 1.0.2
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>
2026-10-28 10:44:23 +01:00

67 lines
1.8 KiB
Go

package main
import (
"slices"
"testing"
)
// The shape of the compatibility table and its handlers in Config.zig 1.4.
const compatZig = `pub const compatibility = std.StaticStringMap(
cli.CompatibilityHandler(Config),
).initComptime(&.{
// Ghostty 1.4 renamed ` + "`scrollback-limit`" + `.
.{ "scrollback-limit", cli.compatibilityRenamed(Config, "scrollback-limit-bytes") },
.{ "bold-is-bright", compatBoldIsBright },
.{ "copy-on-select", compatCopyOnSelect },
});
fn compatBoldIsBright(
self: *Config,
value_: ?[]const u8,
) bool {
const isset = cli.args.parseBool(value_ orelse "t") catch return false;
if (isset) {
self.@"bold-color" = .bright;
}
return true;
}
fn compatCopyOnSelect(
self: *Config,
value: ?[]const u8,
) bool {
if (std.mem.eql(u8, value orelse "", "true")) {
self.@"copy-on-select" = .clipboard;
return true;
}
if (std.mem.eql(u8, value orelse "", "false")) {
self.@"copy-on-select" = .none;
return true;
}
return false;
}
`
func TestParseCompat(t *testing.T) {
got := parseCompat(compatZig)
if len(got) != 3 {
t.Fatalf("%d entries, want 3: %+v", len(got), got)
}
if c := got[0]; c.Key != "scrollback-limit" || c.RenamedTo != "scrollback-limit-bytes" {
t.Errorf("renamed: %+v", c)
}
if c := got[1]; c.Key != "bold-is-bright" || !slices.Equal(c.Sets, []string{"bold-color"}) || len(c.Values) != 0 {
t.Errorf("replaced: %+v", c)
}
if c := got[2]; !slices.Equal(c.Values, []string{"true", "false"}) || len(c.Sets) != 0 {
t.Errorf("old values: %+v", c)
}
}
func TestLimitType(t *testing.T) {
o := optionForType("Limit(usize, 64 * 1024 * 1024)", nil)
if o.Kind != "int" || !slices.Equal(o.Values, []string{"unlimited"}) || o.Min == nil || *o.Min != 0 {
t.Errorf("Limit: %+v", o)
}
}