From 53b353eb7f6140962b886e60f84fee481c04cb34 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 20:04:47 -0400 Subject: [PATCH] test: assert conf.d stays lazy in non-interactive shells Spawns one non-interactive child against the sandboxed config and asserts on what loaded -- abbreviations, key bindings, bang-expansions, the C5 event handlers and the tailscale completion machinery must all be absent. Exit codes name which guard regressed. No wall-clock assertions, so it cannot flake. --- tests/functional.fish | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/functional.fish b/tests/functional.fish index e4d1651..b3e6df7 100644 --- a/tests/functional.fish +++ b/tests/functional.fish @@ -97,6 +97,32 @@ function test_vault_dir_honors_override test "$got" = /tmp/vault-override-check end +function test_conf_d_is_lazy_in_scripts + # A non-interactive shell must not load interactive-only conf.d work. + # The child inherits XDG_CONFIG_HOME from the sandboxed session, so it + # loads the same config under test. Each exit code names one regression. + # + # Assertion 5 (tailscale) is vacuously true where tailscale is not + # installed: conf.d/tailscale.fish returned early on `type -q tailscale` + # before this change, and completions/tailscale.fish does the same, so the + # function is absent either way. The test still cannot fail wrongly there + # -- it just stops proving anything about that one file. A positive + # "completions still work" check would need the binary present and would + # make the suite machine-dependent, so it stays out. + fish -c ' + abbr -q n; and exit 1 + functions -q fish_user_key_bindings; and exit 2 + functions -q expand_bang_all; and exit 3 + functions -q __fish_config_logging_changed; and exit 4 + functions -q __tailscale_perform_completion; and exit 5 + exit 0' +end + +function test_key_bindings_defined + # Positive counterpart to assertion 2 above: the guard must not over-fire. + functions -q fish_user_key_bindings +end + function functional_test_main set -l names (functions -a | string match 'test_*' | sort) set -l failed 0