dotfiles/dot_tmux/plugins/tmux-copycat/test/helpers/expect_helpers.exp
2023-11-13 13:48:17 +01:00

149 lines
2.1 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# a set of expect helpers
# basic setup for each script
proc expect_setup {} {
# disables script output
log_user 0
# standard timeout
set timeout 5
}
proc exit_status_false {} {
global exit_status
set exit_status 1
}
proc sync_tmux {} {
sleep 1.5
}
proc sync_irb {} {
sleep 5.0
}
proc teardown_and_exit {} {
global exit_status
_kill_tmux_server
exit $exit_status
}
proc create_output {} {
# `yes` command just outputs `yes`
send "yes\r"
sleep 0.1
# stop `yes` command
send ""
sync_tmux
}
proc clear_screen {} {
send " "
sync_tmux
}
proc display_text {text} {
send "echo $text\r"
sync_tmux
}
proc new_tmux_pane {} {
sleep 0.3
send "c"
sleep 1.0
}
proc enter_irb {} {
send "irb\r"
sync_irb
}
proc exit_irb {} {
send "\r"
sync_irb
send "exit\r"
sync_tmux
}
proc irb_display_text {text} {
send "puts '$text'\r"
sync_irb
}
# Generates random output just to fill the screen.
proc irb_generate_output {} {
send "puts 'output\n' * 200\r"
sync_irb
}
proc enter_test_git_repo {} {
sync_tmux
send "cd ~/tmux-example-plugin\r"
sync_tmux
send "git checkout --quiet tags/v0.0.1\r"
sync_tmux
}
proc git_status {} {
sync_tmux
send "git status --short\r"
sync_tmux
}
proc git_log_reverse_short {} {
sync_tmux
send "git --no-pager log --reverse --oneline -1\r"
sync_tmux
}
proc git_log_reverse {} {
sync_tmux
send "git --no-pager log --reverse -1\r"
sync_tmux
}
proc git_checkout {} {
sync_tmux
send "git checkout -- .\r"
sync_tmux
}
proc git_clean_fd {} {
sync_tmux
send "git clean -f -d\r"
sync_tmux
}
proc clean_git_repo {} {
git_checkout
git_clean_fd
}
proc change_file {file} {
sync_tmux
send "echo 'change' > $file\r"
sync_tmux
}
proc create_new_file_in_repo {} {
sync_tmux
send "echo 'text' >> new_file.txt\r"
sync_tmux
}
proc remove_test_git_repo {} {
sync_tmux
send "cd ~\r"
sync_tmux
send "rm -rf ~/tmux_example_plugin/\r"
sync_tmux
}
# private functions
proc _kill_tmux_server {} {
send ""
sync_tmux
send "tmux kill-server\r"
sync_tmux
}