Refactor test 'expect' scripts

Make test 'expect' scripts simpler and ensure expectations are properly
asserted.

Closes #46
This commit is contained in:
Bruno Sutic 2015-08-02 22:46:57 +02:00
parent d19c187dcc
commit c435ead1a3
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
7 changed files with 133 additions and 151 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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