mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
xscapes was decided on 09-01 with the repo, and the rename stopped at the module path because going further meant touching live state: the env vars, ~/.config/asciiscapes/, and the marker on twelve hooks already installed in his settings.json. This finishes it. The marker was the whole risk. It is uninstall's only handle on its own work, so changing the constant alone would have left twelve hooks that nothing could see -- uninstall reporting zero, install adding a second copy beside each, and a person editing JSON by hand to remove a tool that said it had gone. install.go now WRITES `# xscapes:v1` and RECOGNISES `# asciiscapes:v1`, and the existing stale-path branch migrates them. The plan says "migrated from asciiscapes:v1" rather than "re-pointed", because the two are different amounts of risk and the reviewer should be told which. Proven by emptying legacyMarkers: the tests go red, and the failure shows the orphan exactly -- Stop ends up with two hooks, one of them invisible. Settings were renamed with a fallback rather than a hard cut, because a rename is the cheapest way there is to build a knob nothing reads: the value looks applied, the picture does not change, and the measurement is wrong with nothing saying so. These are variables typed by hand while judging a frame, so muscle memory is the expected input. internal/envx keeps ASCIISCAPES_* working and names it on stderr once, from the top of main -- the last moment certainly safe to write, since -live, claude and inside take the alternate screen shortly after. hook and statusline are exempt: one runs on every tool call into /dev/null, the other owns a line of the agent's chrome. Writing the test for the warning found it firing on a variable exported empty, which is inert, and a warning that cries wolf on a clean environment is one nobody reads. Left saying asciiscapes on purpose, and these are not leftovers: the legacyMarkers entry, envx's legacyPrefix, the verbatim quotes in _FEEDBACK.md, origin-chat.md's decision pass, and the superseded bullets in RESUME.md. Rewriting a record of what was true then would only make it lie. Live state moved with it: ~/.config/asciiscapes -> ~/.config/xscapes (53 spools, 17 backups), and the twelve hooks migrated with a diff of exactly 24 lines, all marker, nothing else touched. Two spools written into the old path by the still-old binary during the swap were merged back in timestamp order rather than appended. Also drops a duplicated `xscapes tune` line in the help, which predates this and was only visible once the name was read twice. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1u8vp8AgrTuaCCcLv6HVi
69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package envx
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLookupPrefersNewName(t *testing.T) {
|
|
t.Setenv("XSCAPES_COLOR", "new")
|
|
t.Setenv("ASCIISCAPES_COLOR", "old")
|
|
if got := Lookup("COLOR"); got != "new" {
|
|
t.Errorf("Lookup = %q, want the new name to win", got)
|
|
}
|
|
}
|
|
|
|
func TestLookupFallsBackToLegacy(t *testing.T) {
|
|
t.Setenv("XSCAPES_COLOR", "")
|
|
t.Setenv("ASCIISCAPES_COLOR", "256")
|
|
if got := Lookup("COLOR"); got != "256" {
|
|
t.Errorf("Lookup = %q, want the pre-rename name to still work", got)
|
|
}
|
|
}
|
|
|
|
// The positive control for the one above: with neither set, Lookup must be
|
|
// empty. Without this the fallback test passes for a reader that returns "256"
|
|
// unconditionally.
|
|
func TestLookupEmptyWhenNeitherSet(t *testing.T) {
|
|
t.Setenv("XSCAPES_COLOR", "")
|
|
t.Setenv("ASCIISCAPES_COLOR", "")
|
|
if got := Lookup("COLOR"); got != "" {
|
|
t.Errorf("Lookup = %q, want empty", got)
|
|
}
|
|
}
|
|
|
|
func TestWarnLegacyNamesTheVariable(t *testing.T) {
|
|
t.Setenv("ASCIISCAPES_SHADE_BLOCKS", "1")
|
|
var b bytes.Buffer
|
|
WarnLegacy(&b)
|
|
out := b.String()
|
|
if !strings.Contains(out, "ASCIISCAPES_SHADE_BLOCKS") {
|
|
t.Errorf("warning does not name the old variable:\n%s", out)
|
|
}
|
|
if !strings.Contains(out, "XSCAPES_SHADE_BLOCKS") {
|
|
t.Errorf("warning does not name the replacement:\n%s", out)
|
|
}
|
|
}
|
|
|
|
// A warning that fires when nothing is deprecated is noise on every run, which
|
|
// is how a warning gets ignored.
|
|
func TestWarnLegacySilentWhenClean(t *testing.T) {
|
|
t.Setenv("ASCIISCAPES_SHADE_BLOCKS", "")
|
|
var b bytes.Buffer
|
|
WarnLegacy(&b)
|
|
if b.Len() != 0 {
|
|
t.Errorf("warned with no legacy variables set:\n%s", b.String())
|
|
}
|
|
}
|
|
|
|
func TestWarnLegacySaysWhichOneLost(t *testing.T) {
|
|
t.Setenv("XSCAPES_CHROMA", "2.6")
|
|
t.Setenv("ASCIISCAPES_CHROMA", "1.0")
|
|
var b bytes.Buffer
|
|
WarnLegacy(&b)
|
|
if !strings.Contains(b.String(), "ignored") {
|
|
t.Errorf("shadowed variable not reported as ignored:\n%s", b.String())
|
|
}
|
|
}
|