1
0
Fork 0
mirror of synced 2024-07-19 11:00:36 -04:00

Test updates

This commit is contained in:
Bruno Sutic 2014-07-17 21:12:28 +02:00
parent 89ea56f553
commit 9ae07148b4
5 changed files with 18 additions and 15 deletions

2
test/Vagrantfile vendored
View file

@ -8,7 +8,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
d.has_ssh = true
end
# tpm is synced with `/root/tmux_plugin_manager` in vagrant
# tpm is synced to `/root/tmux_plugin_manager` in vagrant
config.vm.synced_folder '../', '/root/tmux_plugin_manager'
config.ssh.username = 'root'

View file

@ -7,7 +7,7 @@ run_vagrant() {
}
stop_vagrant() {
vagrant destroy -f
vagrant halt
}
run_tests() {

View file

@ -1,5 +1,7 @@
#!/usr/bin/env bash
export TEST_FAIL=false
set_tmux_conf_helper() {
> ~/.tmux.conf # empty filename
while read -r line; do
@ -33,8 +35,12 @@ check_dir_exists_helper() {
fi
}
fail_test() {
TEST_FAIL=true
}
exit_value_helper() {
if $FAIL; then
if $TEST_FAIL; then
echo
echo "Test failed"
exit 1

View file

@ -2,23 +2,21 @@
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $CURRENT_DIR/helpers.sh
export FAIL=false
source $CURRENT_DIR/test_helpers.sh
test_plugin_installation() {
set_tmux_conf_helper <<- HERE
set -g @tpm_plugins "bruno-/tmux_example_plugin"
run-shell '~/tmux_plugin_manager/tpm'
run-shell '/root/tmux_plugin_manager/tpm'
HERE
# opens tmux and test it with `expect`
$CURRENT_DIR/expect_successful_plugin_download ||
(echo "Tmux plugin installation fails" >&2; FAIL=true)
(echo "Tmux plugin installation fails" >&2; fail_test)
# check plugin dir exists after download
check_dir_exists_helper "/root/.tmux/plugins/tmux_example_plugin/" ||
(echo "Plugin download fails" >&2; FAIL=true)
(echo "Plugin download fails" >&2; fail_test)
teardown_helper
}

View file

@ -2,9 +2,7 @@
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $CURRENT_DIR/helpers.sh
export FAIL=false
source $CURRENT_DIR/test_helpers.sh
check_binding_defined() {
local binding=$1
@ -15,16 +13,17 @@ test_plugin_sourcing() {
set_tmux_conf_helper <<- HERE
set -g @tpm_plugins "doesnt_matter/tmux_test_plugin"
# change this
run-shell '~/tmux_plugin_manager/tpm'
run-shell '/root/tmux_plugin_manager/tpm'
HERE
# manually creates a local tmux plugin
create_test_plugin_helper <<- HERE
tmux bind-key R run-shell foo_command
HERE
tmux new-session -d # tmux starts detached
check_binding_defined 'R run-shell foo_command' ||
(echo "Plugin sourcing fails" >&2; FAIL=true)
check_binding_defined "R run-shell foo_command" ||
(echo "Plugin sourcing fails" >&2; fail_test)
teardown_helper
}