diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b22377..51dcc39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - switch to using [tmux-test](https://github.com/tmux-plugins/tmux-test) framework - add `bin/update_plugins` cli executable script +- refactor test `expect` scripts, make them simpler and ensure they properly + assert expectations ### v2.0.0, 2015-07-07 - enable overriding default key bindings diff --git a/tests/expect_failed_plugin_download b/tests/expect_failed_plugin_download index 8306347..b970477 100755 --- a/tests/expect_failed_plugin_download +++ b/tests/expect_failed_plugin_download @@ -16,26 +16,21 @@ send "I" set timeout 20 expect_after { - timeout { - puts "Plugin installation timeout" - exit 1 - } + timeout { exit 1 } } expect { - "Installing \"non-existing-plugin\"" { + "Installing \"non-existing-plugin\"" +} - expect { - "\"non-existing-plugin\" download fail" { - - expect { - "Done, press ENTER to continue" { - exit - } - } - - } - } +expect { + "\"non-existing-plugin\" download fail" +} +expect { + "Done, press ENTER to continue" { + exit 0 } } + +exit 1 diff --git a/tests/expect_successful_clean_plugins b/tests/expect_successful_clean_plugins index f6b2e3a..987c49d 100755 --- a/tests/expect_successful_clean_plugins +++ b/tests/expect_successful_clean_plugins @@ -14,17 +14,22 @@ send "u" set timeout 5 -expect { - "Removing \"tmux-example-plugin\"" { - expect { - "\"tmux-example-plugin\" clean success" { - expect { "Done, press ENTER to continue." { exit 0 } } - } - } - } +expect_after { + timeout { exit 1 } +} - timeout { - puts "Plugin update prompt timeout"; - exit 1 +expect { + "Removing \"tmux-example-plugin\"" +} + +expect { + "\"tmux-example-plugin\" clean success" +} + +expect { + "Done, press ENTER to continue." { + exit 0 } } + +exit 1 diff --git a/tests/expect_successful_multiple_plugins_download b/tests/expect_successful_multiple_plugins_download index 931db15..cc87a26 100755 --- a/tests/expect_successful_multiple_plugins_download +++ b/tests/expect_successful_multiple_plugins_download @@ -15,32 +15,30 @@ send "I" # cloning might take a while set timeout 15 -expect { "Installing \"tmux-example-plugin\"" { +expect_after { + timeout { exit 1 } +} - expect { "\"tmux-example-plugin\" download success" { +expect { + "Installing \"tmux-example-plugin\"" +} - expect { "Installing \"tmux-copycat\"" { +expect { + "\"tmux-example-plugin\" download success" +} - expect { "\"tmux-copycat\" download success" { +expect { + "Installing \"tmux-copycat\"" +} - expect { "Done, press ENTER to continue" { - send " " - } - } # Done, press ENTER to continue +expect { + "\"tmux-copycat\" download success" +} - } - } # "tmux-copycat" download success - - } - } # Installing "tmux-copycat" - - } - } # "tmux-example-plugin" download success - - } - - timeout { - puts "Multiple plugins installation timeout"; - exit 1 +expect { + "Done, press ENTER to continue." { + exit 0 } } + +exit 1 diff --git a/tests/expect_successful_plugin_download b/tests/expect_successful_plugin_download index 027af37..388f05d 100755 --- a/tests/expect_successful_plugin_download +++ b/tests/expect_successful_plugin_download @@ -15,40 +15,36 @@ send "I" # cloning might take a while set timeout 15 +expect_after { + timeout { exit 1 } +} + expect { - "Installing \"tmux-example-plugin\"" { + "Installing \"tmux-example-plugin\"" +} - expect { - "\"tmux-example-plugin\" download success" { +expect { + "\"tmux-example-plugin\" download success" +} - expect { "Done, press ENTER to continue" { - send " " - } - } - - } - } - - } - - timeout { - puts "Plugin installation timeout (1)"; - exit 1 +expect { + "Done, press ENTER to continue" { + send " " } } +sleep 1 # this is tmux prefix + I send "I" expect { - "Already installed \"tmux-example-plugin\"" { + "Already installed \"tmux-example-plugin\"" +} - expect { "Done, press ENTER to continue" { exit 0 } } - - } - - timeout { - puts "Plugin installation timeout (2)"; - exit 1 +expect { + "Done, press ENTER to continue" { + exit 0 } } + +exit 1 diff --git a/tests/expect_successful_update_of_a_single_plugin b/tests/expect_successful_update_of_a_single_plugin index cfff332..bcd64fe 100755 --- a/tests/expect_successful_update_of_a_single_plugin +++ b/tests/expect_successful_update_of_a_single_plugin @@ -12,50 +12,44 @@ sleep 1 # this is tmux prefix + U send "U" -set timeout 5 +set timeout 15 -expect { - "Installed plugins" { - - expect { - "\"tmux-example-plugin\"" { - - expect { - "\"all\" - updates all plugins" { - - expect { "ENTER - cancels" } - - } - } - - } - } - - } - - timeout { - puts "Plugin update prompt timeout"; - exit 1 - } +expect_after { + timeout { exit 1 } } +expect { + "Installed plugins" +} + +expect { + "tmux-example-plugin" +} + +expect { + "\"all\" - updates all plugins" +} + +expect { + "ENTER - cancels" +} + +# wait for tmux to display prompt before sending characters +sleep 1 send "tmux-example-plugin\r" expect { - "Updating \"tmux-example-plugin\"" { + "Updating \"tmux-example-plugin\"" +} - expect { - "\"tmux-example-plugin\" update success" { +expect { + "\"tmux-example-plugin\" update success" +} - expect { "Done, press ENTER to continue." { exit 0 } } - - } - } - - } - - timeout { - puts "Update all plugins timeout"; - exit 1 +expect { + "Done, press ENTER to continue." { + exit 0 } } + +exit 1 diff --git a/tests/expect_successful_update_of_all_plugins b/tests/expect_successful_update_of_all_plugins index 4705edd..4f3a4a3 100755 --- a/tests/expect_successful_update_of_all_plugins +++ b/tests/expect_successful_update_of_all_plugins @@ -14,54 +14,46 @@ send "U" set timeout 5 -expect { - "Installed plugins" { - - expect { - "\"tmux-example-plugin\"" { - - expect { - "\"all\" - updates all plugins" { - - expect { "ENTER - cancels" } - - } - } - - } - } - - } - - timeout { - puts "Plugin update prompt timeout"; - exit 1 - } +expect_after { + timeout { exit 1 } } +expect { + "Installed plugins" +} + +expect { + "tmux-example-plugin" +} + +expect { + "\"all\" - updates all plugins" +} + +expect { + "ENTER - cancels" +} + +# wait for tmux to display prompt before sending characters +sleep 1 send "all\r" expect { - "Updating all plugins!" { + "Updating all plugins!" +} - expect { - "Updating \"tmux-example-plugin\"" { +expect { + "Updating \"tmux-example-plugin\"" +} - expect { - "\"tmux-example-plugin\" update success" { +expect { + "\"tmux-example-plugin\" update success" +} - expect { "Done, press ENTER to continue." { exit 0 } } - - } - } - - } - } - - } - - timeout { - puts "Update all plugins timeout"; - exit 1 +expect { + "Done, press ENTER to continue." { + exit 0 } } + +exit 1