From 328e30882e160cd3f75ee578a3f21745748f288b Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 20:12:59 -0400 Subject: [PATCH] test: assert converted functions still emit colour in --help Runtime escape-presence check over 24 user-facing functions. Deliberately not a static grep for __fish_palette: measured on a broken logs.fish whose --help block lost its declarations without gaining a call, `fish -n` exited 0 and `grep -c __fish_palette` returned 1 while the help output went 431 B -> 150 B with every escape stripped. The full suite was green too. Only running the function and looking for an \e byte catches it; that demonstration is recorded as a comment above the test. Verified red as well as green -- deleting the __fish_palette call from functions/mkcd.fish yields: --help lost its colour: mkcd FAIL test_functions_keep_their_palette 16/17 passed fish_prompt.fish is excluded by name (its own hex palette); qc is excluded because its --help shells out to aichat, which CI lacks. --- tests/functional.fish | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/functional.fish b/tests/functional.fish index 68c64e8..590068c 100644 --- a/tests/functional.fish +++ b/tests/functional.fish @@ -124,6 +124,53 @@ function test_palette_roles_defined return 0 end +# Every user-facing function that renders a coloured --help must still emit +# escape sequences. +# +# This is deliberately a RUNTIME check, never a static grep for +# __fish_palette. Measured on a deliberately broken functions/logs.fish -- +# the palette call de-duplicated per indentation depth instead of per +# contiguous run, so the --help block lost its declarations without gaining +# a call: +# +# fish tests/palette-bytes.fish +# FAIL logs --help stdout=DIFF stderr=ok +# baseline 431 B -> broken 150 B (every escape stripped) +# +# fish -n functions/logs.fish -> exit 0 (lint PASSES) +# grep -c '__fish_palette' logs.fish -> 1 (grep PASSES) +# +# Both cheap checks are green on a file whose help output has lost all of +# its colour. Only running the function and looking for an \e byte catches +# it. The full test suite was also green throughout. +# +# functions/fish_prompt.fish is excluded BY NAME. It interpolates $c_dim +# from its own Catppuccin hex palette -- those are colour arguments passed +# to set_color, not captured escapes -- so it legitimately never calls +# __fish_palette and would otherwise look unconverted forever. +# +# qc is absent from the list on purpose: its --help shells out to aichat, +# which is not installed in CI, so its colour path is unreachable here. +# tests/palette-bytes.fish stubs aichat and does cover it. +function test_functions_keep_their_palette + set -l colored agents-init agents-vault auto-pull config-settings \ + config-update detach dng2avif dockup edit jobrunner kitty-logging \ + logs mkcd open-url p pkg play-media rand_string replay repo-open \ + scrub smart_exit spark y + set -l uncolored + for fn in $colored + functions -q $fn; or continue + if not $fn --help 2>&1 | string match -qr \e + set -a uncolored $fn + end + end + if test (count $uncolored) -gt 0 + echo " --help lost its colour: $uncolored" + return 1 + end + return 0 +end + function functional_test_main set -l names (functions -a | string match 'test_*' | sort) set -l failed 0