tpm/tests/helpers.sh

56 lines
834 B
Bash
Raw Normal View History

2014-05-24 13:38:41 +00:00
#!/usr/bin/env bash
2014-07-17 20:16:46 +00:00
FAIL="false"
2014-07-17 19:12:28 +00:00
2014-05-24 13:38:41 +00:00
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
}
2014-07-17 20:16:46 +00:00
fail_helper() {
local message="$1"
2014-07-17 20:51:07 +00:00
echo "$message" >&2
2014-07-17 20:16:46 +00:00
FAIL="true"
2014-07-17 19:12:28 +00:00
}
2014-05-24 13:38:41 +00:00
exit_value_helper() {
2014-07-17 20:16:46 +00:00
local fail="$1"
if [ "$FAIL" == "true" ]; then
echo "FAIL!"
2014-05-24 21:18:37 +00:00
echo
exit 1
else
echo "SUCCESS"
2014-05-24 21:18:37 +00:00
echo
exit 0
fi
2014-05-24 13:38:41 +00:00
}