1
0
Fork 0
mirror of synced 2024-11-16 06:25:36 -05:00
tpm/tests/helpers.sh

56 lines
834 B
Bash
Raw Normal View History

2014-05-24 09:38:41 -04:00
#!/usr/bin/env bash
2014-07-17 16:16:46 -04:00
FAIL="false"
2014-07-17 15:12:28 -04:00
2014-05-24 09:38:41 -04:00
set_tmux_conf_helper() {
2014-05-24 17:18:37 -04:00
> ~/.tmux.conf # empty filename
while read -r line; do
echo $line >> ~/.tmux.conf
done
2014-05-24 09:38:41 -04:00
}
create_test_plugin_helper() {
2014-05-24 17:18:37 -04:00
local plugin_path="$HOME/.tmux/plugins/tmux_test_plugin/"
rm -rf $plugin_path
mkdir -p $plugin_path
2014-05-24 09:38:41 -04:00
2014-05-24 17:18:37 -04:00
while read -r line; do
echo $line >> "$plugin_path/test_plugin.tmux"
done
chmod +x "$plugin_path/test_plugin.tmux"
2014-05-24 09:38:41 -04:00
}
teardown_helper() {
2014-05-24 17:18:37 -04:00
rm ~/.tmux.conf
rm -rf ~/.tmux/
tmux kill-server >/dev/null 2>&1
2014-05-24 09:38:41 -04:00
}
check_dir_exists_helper() {
2014-05-24 17:18:37 -04:00
local dir_path=$1
if [ -d "$dir_path" ]; then
return 0
else
return 1
fi
2014-05-24 09:38:41 -04:00
}
2014-07-17 16:16:46 -04:00
fail_helper() {
local message="$1"
2014-07-17 16:51:07 -04:00
echo "$message" >&2
2014-07-17 16:16:46 -04:00
FAIL="true"
2014-07-17 15:12:28 -04:00
}
2014-05-24 09:38:41 -04:00
exit_value_helper() {
2014-07-17 16:16:46 -04:00
local fail="$1"
if [ "$FAIL" == "true" ]; then
echo "FAIL!"
2014-05-24 17:18:37 -04:00
echo
exit 1
else
echo "SUCCESS"
2014-05-24 17:18:37 -04:00
echo
exit 0
fi
2014-05-24 09:38:41 -04:00
}