tests/zsh: add xdg dotDir tests

Verify we respect xdg.enable behavior when placing files.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman
2025-12-27 13:13:19 -06:00
parent d761c0ce89
commit b3ae822959
4 changed files with 73 additions and 0 deletions

View File

@@ -19,12 +19,15 @@
zsh-history-path-xdg-variable = import ./history-path.nix "xdg-variable";
zsh-history-path-zdotdir-variable = import ./history-path.nix "zdotdir-variable";
zsh-history-substring-search = ./history-substring-search.nix;
zsh-legacy-warning = ./legacy-warning.nix;
zsh-siteFunctions-mkcd = ./siteFunctions-mkcd.nix;
zsh-plugins = ./plugins.nix;
zsh-prezto = ./prezto.nix;
zsh-session-variables = ./session-variables.nix;
zsh-smart-formatting = ./smart-formatting.nix;
zsh-syntax-highlighting = ./syntax-highlighting.nix;
zsh-xdg-default = ./xdg-default.nix;
zsh-xdg-disabled = ./xdg-disabled.nix;
zsh-zprof = ./zprof.nix;
zshrc-contents-priorities = ./zshrc-content-priorities.nix;
}

View File

@@ -0,0 +1,29 @@
{
config = {
programs.zsh.enable = true;
xdg.enable = true;
# We use 25.05 to trigger the legacy warning (since < 26.05)
# AND to bypass the global fix in tests/default.nix (which checks for 18.09)
home.stateVersion = "25.05";
nmt.script = ''
assertFileExists home-files/.zshrc
# Verify that the warning is generated
# We check the evaluation output for the warning message
assertPathNotExists home-files/.config/zsh
'';
test.asserts.warnings.expected = [
''
The default value of `programs.zsh.dotDir` will change in future versions.
You are currently using the legacy default (home directory) because `home.stateVersion` is less than "26.05".
To silence this warning and lock in the current behavior, set:
programs.zsh.dotDir = config.home.homeDirectory;
To adopt the new behavior (XDG config directory), update `home.stateVersion` to "26.05" or set:
programs.zsh.dotDir = "''${config.xdg.configHome}/zsh";
''
];
};
}

View File

@@ -0,0 +1,21 @@
{
config = {
programs.zsh.enable = true;
home.stateVersion = "26.05";
xdg.enable = true;
# With xdg.enable = true and new state version, dotDir should default to XDG config home
nmt.script = ''
assertFileExists home-files/.config/zsh/.zshenv
assertFileExists home-files/.config/zsh/.zshrc
# Verify global .zshenv points to the XDG location
assertFileExists home-files/.zshenv
assertFileRegex home-files/.zshenv "source /home/hm-user/.config/zsh/.zshenv"
# Verify ZDOTDIR is exported in the inner .zshenv
assertFileRegex home-files/.config/zsh/.zshenv "export ZDOTDIR=\"/home/hm-user/.config/zsh\""
'';
};
}

View File

@@ -0,0 +1,20 @@
{
config = {
programs.zsh.enable = true;
xdg.enable = false;
home.stateVersion = "26.05";
# With xdg.enable = false, dotDir should default to home directory regardless of state version
nmt.script = ''
assertFileExists home-files/.zshenv
assertFileExists home-files/.zshrc
# Should NOT exist in XDG location
assertPathNotExists home-files/.config/zsh
# Verify ZDOTDIR is NOT exported (or points to home if it is, but usually it isn't if dotDir is home)
assertFileNotRegex home-files/.zshenv "export ZDOTDIR="
'';
};
}