tests/zsh: add more path test cases
Test the new lib file path function Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
938ecd797f
commit
9ff467fbe7
3 changed files with 55 additions and 18 deletions
|
|
@ -4,10 +4,13 @@
|
|||
zsh-dotdir-absolute = import ./dotdir.nix "absolute";
|
||||
zsh-dotdir-default = import ./dotdir.nix "default";
|
||||
zsh-dotdir-relative = import ./dotdir.nix "relative";
|
||||
zsh-dotdir-xdg-variable = import ./dotdir.nix "xdg-variable";
|
||||
zsh-history-ignore-pattern = ./history-ignore-pattern.nix;
|
||||
zsh-history-path-absolute = import ./history-path.nix "absolute";
|
||||
zsh-history-path-default = import ./history-path.nix "default";
|
||||
zsh-history-path-relative = import ./history-path.nix "relative";
|
||||
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-plugins = ./plugins.nix;
|
||||
zsh-prezto = ./prezto.nix;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ let
|
|||
subDir
|
||||
else if case == "default" then
|
||||
options.programs.zsh.dotDir.default
|
||||
else if case == "xdg-variable" then
|
||||
"\${XDG_CONFIG_HOME:-\$HOME/.config}/zsh"
|
||||
else
|
||||
abort "Test condition not provided.";
|
||||
|
||||
|
|
@ -33,20 +35,28 @@ in
|
|||
|
||||
test.stubs.zsh = { };
|
||||
|
||||
nmt.script = lib.concatStringsSep "\n" [
|
||||
# check dotDir entrypoint exists
|
||||
"assertFileExists home-files/${relDotDir}/.zshenv"
|
||||
nmt.script =
|
||||
if case == "xdg-variable" then
|
||||
''
|
||||
# For XDG variable case, check that shell variables are preserved in the generated shell code
|
||||
# The fixed implementation should preserve variables without wrapping them in single quotes
|
||||
assertFileContains home-files/.zshenv 'source ''${XDG_CONFIG_HOME:-''$HOME/.config}/zsh/.zshenv'
|
||||
''
|
||||
else
|
||||
lib.concatStringsSep "\n" [
|
||||
# check dotDir entrypoint exists
|
||||
"assertFileExists home-files/${relDotDir}/.zshenv"
|
||||
|
||||
# for non-default dotDir only:
|
||||
(lib.optionalString (case != "default") ''
|
||||
# check .zshenv in homeDirectory sources .zshenv in dotDir
|
||||
assertFileRegex home-files/.zshenv \
|
||||
"source [\"']\?${absDotDir}/.zshenv[\"']\?"
|
||||
# for non-default dotDir only:
|
||||
(lib.optionalString (case != "default") ''
|
||||
# check .zshenv in homeDirectory sources .zshenv in dotDir
|
||||
assertFileRegex home-files/.zshenv \
|
||||
"source [\"']\?${absDotDir}/.zshenv[\"']\?"
|
||||
|
||||
# check that .zshenv in dotDir exports ZDOTDIR
|
||||
assertFileRegex home-files/${relDotDir}/.zshenv \
|
||||
"export ZDOTDIR=[\"']\?${absDotDir}[\"']\?"
|
||||
'')
|
||||
];
|
||||
# check that .zshenv in dotDir exports ZDOTDIR
|
||||
assertFileRegex home-files/${relDotDir}/.zshenv \
|
||||
"export ZDOTDIR=[\"']\?${absDotDir}[\"']\?"
|
||||
'')
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
case:
|
||||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
homeDir = config.home.homeDirectory;
|
||||
|
|
@ -20,22 +20,46 @@ let
|
|||
customHistRelPath
|
||||
else if case == "default" then
|
||||
defaultHistPath
|
||||
else if case == "xdg-variable" then
|
||||
"\${XDG_STATE_HOME:-\$HOME/.local/state}/zsh/history"
|
||||
else if case == "zdotdir-variable" then
|
||||
"\$ZDOTDIR/.zsh_history"
|
||||
else
|
||||
abort "Test condition not provided";
|
||||
|
||||
expectedPath = if case == "default" then defaultHistPath else customHistAbsPath;
|
||||
expectedPath =
|
||||
if case == "default" then
|
||||
defaultHistPath
|
||||
else if case == "xdg-variable" then
|
||||
"\${XDG_STATE_HOME:-\$HOME/.local/state}/zsh/history"
|
||||
else if case == "zdotdir-variable" then
|
||||
"\$ZDOTDIR/.zsh_history"
|
||||
else
|
||||
customHistAbsPath;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
history.path = testPath;
|
||||
dotDir = lib.mkIf (case == "zdotdir-variable") "${homeDir}/.config/zsh";
|
||||
};
|
||||
|
||||
test.stubs.zsh = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.zshrc '^HISTFILE="${expectedPath}"$'
|
||||
'';
|
||||
nmt.script =
|
||||
if case == "xdg-variable" then
|
||||
''
|
||||
assertFileContains home-files/.zshrc 'HISTFILE="''${XDG_STATE_HOME:-''$HOME/.local/state}/zsh/history"'
|
||||
''
|
||||
else if case == "zdotdir-variable" then
|
||||
''
|
||||
assertFileContains home-files/.config/zsh/.zshrc 'HISTFILE="$ZDOTDIR/.zsh_history"'
|
||||
assertFileContains home-files/.config/zsh/.zshenv "export ZDOTDIR=${homeDir}/.config/zsh"
|
||||
''
|
||||
else
|
||||
''
|
||||
assertFileRegex home-files/.zshrc '^HISTFILE="${expectedPath}"$'
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue