Improve tests

This commit is contained in:
Bruno Sutic 2015-06-02 22:47:32 +02:00
parent 5bbe60dc42
commit 9eee9c06b6
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
3 changed files with 72 additions and 4 deletions

View File

@ -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
}
}

View File

@ -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

View File

@ -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