tpm/test/tests/helpers.sh

47 lines
739 B
Bash
Raw Normal View History

2014-05-24 13:38:41 +00:00
#!/usr/bin/env bash
set_tmux_conf_helper() {
2014-05-24 21:18:37 +00:00
> ~/.tmux.conf # empty filename
while read -r line; do
echo $line >> ~/.tmux.conf
done
2014-05-24 13:38:41 +00:00
}
create_test_plugin_helper() {
2014-05-24 21:18:37 +00:00
local plugin_path="$HOME/.tmux/plugins/tmux_test_plugin/"
rm -rf $plugin_path
mkdir -p $plugin_path
2014-05-24 13:38:41 +00:00
2014-05-24 21:18:37 +00:00
while read -r line; do
echo $line >> "$plugin_path/test_plugin.tmux"
done
chmod +x "$plugin_path/test_plugin.tmux"
2014-05-24 13:38:41 +00:00
}
teardown_helper() {
2014-05-24 21:18:37 +00:00
rm ~/.tmux.conf
rm -rf ~/.tmux/
tmux kill-server >/dev/null 2>&1
2014-05-24 13:38:41 +00:00
}
check_dir_exists_helper() {
2014-05-24 21:18:37 +00:00
local dir_path=$1
if [ -d "$dir_path" ]; then
return 0
else
return 1
fi
2014-05-24 13:38:41 +00:00
}
exit_value_helper() {
2014-05-24 21:18:37 +00:00
if $FAIL; then
echo
echo "Test failed"
exit 1
else
echo
echo "Test finished successfully"
exit 0
fi
2014-05-24 13:38:41 +00:00
}