mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
tests/zsh: add comprehensive smart formatting test
Add test to verify intelligent width optimization of shell arrays. The test demonstrates how formatShellArrayContent packs multiple items per line within reasonable width limits rather than one item per line. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
3aaf340173
commit
26ace005b7
2 changed files with 87 additions and 0 deletions
40
tests/modules/programs/zsh/smart-formatting-expected.zshrc
Normal file
40
tests/modules/programs/zsh/smart-formatting-expected.zshrc
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
typeset -U path cdpath fpath manpath
|
||||
for profile in ${(z)NIX_PROFILES}; do
|
||||
fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
|
||||
done
|
||||
|
||||
HELPDIR="@zsh@/share/zsh/$ZSH_VERSION/help"
|
||||
|
||||
autoload -U compinit && compinit
|
||||
# History options should be set in .zshrc and after oh-my-zsh sourcing.
|
||||
# See https://github.com/nix-community/home-manager/issues/177.
|
||||
HISTSIZE="50000"
|
||||
SAVEHIST="50000"
|
||||
|
||||
HISTFILE="/home/hm-user/.zsh_history"
|
||||
mkdir -p "$(dirname "$HISTFILE")"
|
||||
|
||||
setopt HIST_FCNTL_LOCK
|
||||
|
||||
# Disabled history options
|
||||
disabled_opts=(
|
||||
APPEND_HISTORY EXTENDED_HISTORY HIST_EXPIRE_DUPS_FIRST HIST_FIND_NO_DUPS
|
||||
HIST_IGNORE_ALL_DUPS HIST_IGNORE_DUPS HIST_IGNORE_SPACE HIST_SAVE_NO_DUPS
|
||||
SHARE_HISTORY
|
||||
)
|
||||
for opt in "${disabled_opts[@]}"; do
|
||||
unsetopt "$opt"
|
||||
done
|
||||
unset opt disabled_opts
|
||||
|
||||
# Set shell options
|
||||
set_opts=(
|
||||
AUTO_LIST AUTO_PARAM_SLASH AUTO_PUSHD ALWAYS_TO_END CORRECT HIST_FCNTL_LOCK
|
||||
HIST_VERIFY INTERACTIVE_COMMENTS MENU_COMPLETE PUSHD_IGNORE_DUPS PUSHD_TO_HOME
|
||||
PUSHD_SILENT NOTIFY PROMPT_SUBST MULTIOS NOFLOWCONTROL NO_CORRECT_ALL
|
||||
NO_HIST_BEEP NO_NOMATCH
|
||||
)
|
||||
for opt in "${set_opts[@]}"; do
|
||||
setopt "$opt"
|
||||
done
|
||||
unset opt set_opts
|
||||
47
tests/modules/programs/zsh/smart-formatting.nix
Normal file
47
tests/modules/programs/zsh/smart-formatting.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
# Add many setOptions to trigger multi-line formatting
|
||||
setOptions = [
|
||||
"AUTO_LIST"
|
||||
"AUTO_PARAM_SLASH"
|
||||
"AUTO_PUSHD"
|
||||
"ALWAYS_TO_END"
|
||||
"CORRECT"
|
||||
"HIST_FCNTL_LOCK"
|
||||
"HIST_VERIFY"
|
||||
"INTERACTIVE_COMMENTS"
|
||||
"MENU_COMPLETE"
|
||||
"PUSHD_IGNORE_DUPS"
|
||||
"PUSHD_TO_HOME"
|
||||
"PUSHD_SILENT"
|
||||
"NOTIFY"
|
||||
"PROMPT_SUBST"
|
||||
"MULTIOS"
|
||||
"NOFLOWCONTROL"
|
||||
"NO_CORRECT_ALL"
|
||||
"NO_HIST_BEEP"
|
||||
"NO_NOMATCH"
|
||||
];
|
||||
# This should also show intelligent formatting for history options
|
||||
history = {
|
||||
size = 50000;
|
||||
save = 50000;
|
||||
# These will create many disabled options
|
||||
append = false;
|
||||
ignoreDups = false;
|
||||
ignoreAllDups = false;
|
||||
saveNoDups = false;
|
||||
findNoDups = false;
|
||||
ignoreSpace = false;
|
||||
expireDuplicatesFirst = false;
|
||||
extended = false;
|
||||
share = false;
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshrc
|
||||
assertFileContent home-files/.zshrc ${./smart-formatting-expected.zshrc}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue