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 d.has_ssh = true
end 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.vm.synced_folder '../', '/root/tmux_plugin_manager'
config.ssh.username = 'root' config.ssh.username = 'root'

View File

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

View File

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

View File

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

View File

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