antidote/tests/test_zsetopts.md

1.9 KiB

antidote respects setopts

Setup

% source ./tests/__init__.zsh
% t_setup
%

Set up a plugin that changes Zsh options

% plugin_file=$ANTIDOTE_HOME/lampoon/xmas/xmas.plugin.zsh
% mkdir -p $plugin_file:h && touch $plugin_file
% echo "unsetopt noaliases" >>$plugin_file
% echo "setopt autocd" >>$plugin_file
% echo "lampoon/xmas" >$ZDOTDIR/.zsh_plugins.txt
%

Test that plugins that run setopts work

Verify initial state

% setopt noaliases
% set -o | grep noaliases
noaliases             on
% set -o | grep autocd
autocd                off
%

Load the plugins and see if the option took

% antidote load &>/dev/null  #=> --exit 0
% set -o | grep noaliases
noaliases             off
% set -o | grep autocd
autocd                on
% # cleanup
% setopt noaliases no_autocd
%

Tests to ensure #86 stays fixed. Check that stderr is empty.

% setopt posix_identifiers
% antidote -v 3>&1 2>&3 >/dev/null #=> --exit 0

% antidote -h 3>&1 2>&3 >/dev/null #=> --exit 0

% antidote help 3>&1 2>&3 >/dev/null #=> --exit 0

% # cleanup
% unsetopt posix_identifiers
%

Clark Grizwold lighting ceremony!

via GIPHY

% optcnt=$(setopt | wc -l | tr -d ' ')
% echo $optcnt  #=> --regex ^\d+$
% test $optcnt -lt 10 && echo "less than 10 enabled zsh opts"
less than 10 enabled zsh opts
% # now lets turn on all the lights
% echo '$ZDOTDIR/custom/plugins/grizwold' >$ZDOTDIR/.zsh_plugins.txt
% antidote load
% optcnt=$(setopt | wc -l | tr -d ' ')
% test $optcnt -gt 150 && echo "zillions of enabled zsh options (>150)"
zillions of enabled zsh options (>150)
%

Teardown

% unsetopt $grizwold_zopts
% t_teardown
%