diff --git a/test/Vagrantfile b/test/Vagrantfile index db4c03d..868abbf 100644 --- a/test/Vagrantfile +++ b/test/Vagrantfile @@ -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' diff --git a/test/run b/test/run index 318f1df..ec36b41 100755 --- a/test/run +++ b/test/run @@ -7,7 +7,7 @@ run_vagrant() { } stop_vagrant() { - vagrant destroy -f + vagrant halt } run_tests() { diff --git a/test/tests/helpers.sh b/test/tests/test_helpers.sh similarity index 90% rename from test/tests/helpers.sh rename to test/tests/test_helpers.sh index 207fafc..a5f7b97 100644 --- a/test/tests/helpers.sh +++ b/test/tests/test_helpers.sh @@ -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 diff --git a/test/tests/test_plugin_installation.sh b/test/tests/test_plugin_installation.sh index 57a8731..7594417 100755 --- a/test/tests/test_plugin_installation.sh +++ b/test/tests/test_plugin_installation.sh @@ -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 } diff --git a/test/tests/test_plugin_sourcing.sh b/test/tests/test_plugin_sourcing.sh index 0f89f7f..a63146a 100755 --- a/test/tests/test_plugin_sourcing.sh +++ b/test/tests/test_plugin_sourcing.sh @@ -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 }