Compare commits

...
Author SHA1 Message Date
Nick 524cd045bd test(tui-selection): freeze the OSC 52 capability-detection law (#2532)
deploy / deploy (push) Skipped
CI Pipeline / lint (push) Failing after 44s
CI Pipeline / go-surface (push) Failing after 25s
CI Pipeline / rust-surface (push) Failing after 8s
CI Pipeline / canary (push) Failing after 2m39s
CI Pipeline / best-practices (push) Successful in 3s
CI Pipeline / documentation (push) Successful in 2s
CI Pipeline / type-check (push) Failing after 41s
CI Pipeline / gitea-offline (push) Successful in 14s
CI Pipeline / unit-tests (push) Failing after 27m52s
CI Pipeline / required-checks (push) Failing after 1s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Failing after 6s
The drag-select + auto-copy behavior shipped in 1ea093ad, but its
detection seam — the wireOSC52Detection law the real main() installs —
had no coverage: the degrade was only asserted through the injectable
osc52Allowed gate. This freezes the honest-degrade contract: known
non-carrier terminals (dumb et al.) and emacs shells highlight without
copying, a modern carrier copies, and the explicit RUNE_NO_OSC52
opt-out wins over detection.
2026-10-24 22:42:59 +01:00
+38
View File
@@ -196,3 +196,41 @@ func TestMotionRoutesThroughShell(t *testing.T) {
t.Fatal("the release must finish the selection")
}
}
// The capability-detection law itself (the wireOSC52Detection seam the
// real main() installs): known non-carrier terminals and the explicit
// RUNE_NO_OSC52 opt-out degrade to highlight-only; a modern carrier
// copies.
func TestOSC52DetectionDegradesHonestly(t *testing.T) {
term := os.Getenv("TERM")
noosc := os.Getenv("RUNE_NO_OSC52")
emacs := os.Getenv("INSIDE_EMACS")
t.Setenv("RUNE_NO_OSC52", "")
t.Setenv("INSIDE_EMACS", "")
defer func() {
os.Setenv("TERM", term)
os.Setenv("RUNE_NO_OSC52", noosc)
os.Setenv("INSIDE_EMACS", emacs)
}()
wireOSC52Detection()
defer func() { osc52Allowed = func() bool { return false } }()
t.Setenv("TERM", "dumb")
if osc52Allowed() {
t.Fatal("a known non-carrier (dumb) must degrade to highlight-only")
}
t.Setenv("TERM", "xterm-256color")
if !osc52Allowed() {
t.Fatal("a modern carrier terminal must be allowed to copy")
}
t.Setenv("RUNE_NO_OSC52", "1")
if osc52Allowed() {
t.Fatal("the explicit RUNE_NO_OSC52 opt-out must win over detection")
}
t.Setenv("RUNE_NO_OSC52", "")
t.Setenv("INSIDE_EMACS", "t")
if osc52Allowed() {
t.Fatal("an emacs shell must degrade to highlight-only")
}
}