From 9eee9c06b63c3d37212ca59227c3106f445ce0b7 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Tue, 2 Jun 2015 22:47:32 +0200 Subject: [PATCH] Improve tests --- ...xpect_successful_multiple_plugins_download | 46 +++++++++++++++++++ tests/test_plugin_installation.sh | 26 ++++++++++- ....sh => test_plugin_installation_legacy.sh} | 4 +- 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100755 tests/expect_successful_multiple_plugins_download rename tests/{test_plugin_bundle_installation.sh => test_plugin_installation_legacy.sh} (83%) diff --git a/tests/expect_successful_multiple_plugins_download b/tests/expect_successful_multiple_plugins_download new file mode 100755 index 0000000..931db15 --- /dev/null +++ b/tests/expect_successful_multiple_plugins_download @@ -0,0 +1,46 @@ +#!/usr/bin/env expect + +# disables script output +log_user 0 + +spawn tmux + +# Waiting for tmux to attach. If this is not done, next command, `send` will +# not work properly. +sleep 1 + +# this is tmux prefix + I +send "I" + +# cloning might take a while +set timeout 15 + +expect { "Installing \"tmux-example-plugin\"" { + + expect { "\"tmux-example-plugin\" download success" { + + expect { "Installing \"tmux-copycat\"" { + + expect { "\"tmux-copycat\" download success" { + + expect { "Done, press ENTER to continue" { + send " " + } + } # Done, press ENTER to continue + + } + } # "tmux-copycat" download success + + } + } # Installing "tmux-copycat" + + } + } # "tmux-example-plugin" download success + + } + + timeout { + puts "Multiple plugins installation timeout"; + exit 1 + } +} diff --git a/tests/test_plugin_installation.sh b/tests/test_plugin_installation.sh index fb9de71..da487ba 100755 --- a/tests/test_plugin_installation.sh +++ b/tests/test_plugin_installation.sh @@ -6,12 +6,12 @@ source $CURRENT_DIR/helpers.sh test_plugin_installation() { set_tmux_conf_helper <<- HERE - set -g @tpm_plugins "tmux-plugins/tmux-example-plugin" + set @plugin "tmux-plugins/tmux-example-plugin" run-shell "$PWD/tpm" HERE # opens tmux and test it with `expect` - $CURRENT_DIR/expect_successful_plugin_download || + "$CURRENT_DIR"/expect_successful_plugin_download || fail_helper "Tmux plugin installation fails" # check plugin dir exists after download @@ -21,8 +21,30 @@ test_plugin_installation() { teardown_helper } +test_multiple_plugins_installation() { + set_tmux_conf_helper <<- HERE + set @plugin "tmux-plugins/tmux-example-plugin" + set @plugin 'tmux-plugins/tmux-copycat' + run-shell "$PWD/tpm" + HERE + + # opens tmux and test it with `expect` + "$CURRENT_DIR"/expect_successful_multiple_plugins_download || + fail_helper "Tmux multiple plugins installation fails" + + # check plugin dir exists after download + check_dir_exists_helper "$HOME/.tmux/plugins/tmux-example-plugin/" || + fail_helper "Plugin download fails (tmux-example-plugin)" + + check_dir_exists_helper "$HOME/.tmux/plugins/tmux-copycat/" || + fail_helper "Plugin download fails (tmux-copycat)" + + teardown_helper +} + main() { test_plugin_installation + test_multiple_plugins_installation exit_value_helper } main diff --git a/tests/test_plugin_bundle_installation.sh b/tests/test_plugin_installation_legacy.sh similarity index 83% rename from tests/test_plugin_bundle_installation.sh rename to tests/test_plugin_installation_legacy.sh index 0fed45b..fb9de71 100755 --- a/tests/test_plugin_bundle_installation.sh +++ b/tests/test_plugin_installation_legacy.sh @@ -6,12 +6,12 @@ source $CURRENT_DIR/helpers.sh test_plugin_installation() { set_tmux_conf_helper <<- HERE - set @plugin "tmux-plugins/tmux-example-plugin" + set -g @tpm_plugins "tmux-plugins/tmux-example-plugin" run-shell "$PWD/tpm" HERE # opens tmux and test it with `expect` - "$CURRENT_DIR"/expect_successful_plugin_download || + $CURRENT_DIR/expect_successful_plugin_download || fail_helper "Tmux plugin installation fails" # check plugin dir exists after download