mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-24 22:08:46 +00:00
Test resurrect save feature
This commit is contained in:
parent
ac86e025ad
commit
30366a3cb4
19
tests/fixtures/save_file.txt
vendored
Normal file
19
tests/fixtures/save_file.txt
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
pane blue 0 :vim 0 : 0 :/tmp 1 vim :vim foo.txt
|
||||
pane blue 1 :man 0 :- 0 :/tmp 0 bash :
|
||||
pane blue 1 :man 0 :- 1 :/usr/share/man 1 man :man echo
|
||||
pane blue 2 :bash 1 :* 0 :/tmp 1 bash :
|
||||
pane red 0 :bash 0 : 0 :/tmp 1 bash :
|
||||
pane red 1 :bash 0 :- 0 :/tmp 0 bash :
|
||||
pane red 1 :bash 0 :- 1 :/tmp 0 bash :
|
||||
pane red 1 :bash 0 :- 2 :/tmp 1 bash :
|
||||
pane red 2 :bash 1 :* 0 :/tmp 0 bash :
|
||||
pane red 2 :bash 1 :* 1 :/tmp 1 bash :
|
||||
pane yellow 0 :bash 1 :* 0 :/tmp/bar 1 bash :
|
||||
window blue 0 0 : cea3,200x49,0,0,6
|
||||
window blue 1 0 :- 1795,200x49,0,0{100x49,0,0,7,99x49,101,0,8}
|
||||
window blue 2 1 :* cea6,200x49,0,0,9
|
||||
window red 0 0 : ce9d,200x49,0,0,0
|
||||
window red 1 0 :- 9296,200x49,0,0[200x24,0,0,1,200x24,0,25{100x24,0,25,2,99x24,101,25,3}]
|
||||
window red 2 1 :* 3d66,200x49,0,0[200x24,0,0,4,200x24,0,25,5]
|
||||
window yellow 0 1 :* 677f,200x49,0,0,10
|
||||
state yellow blue
|
42
tests/helpers/create_and_save_tmux_test_environment.exp
Executable file
42
tests/helpers/create_and_save_tmux_test_environment.exp
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env expect
|
||||
|
||||
source "./tests/helpers/expect_helpers.exp"
|
||||
|
||||
expect_setup
|
||||
|
||||
spawn tmux
|
||||
# delay with sleep to compensate for tmux starting time
|
||||
sleep 1
|
||||
|
||||
run_shell_command "cd /tmp"
|
||||
|
||||
# session red
|
||||
rename_current_session "red"
|
||||
|
||||
new_tmux_window
|
||||
horizontal_split
|
||||
vertical_split
|
||||
|
||||
new_tmux_window
|
||||
horizontal_split
|
||||
|
||||
# session blue
|
||||
new_tmux_session "blue"
|
||||
|
||||
run_shell_command "touch foo.txt"
|
||||
run_shell_command "vim foo.txt"
|
||||
|
||||
new_tmux_window
|
||||
vertical_split
|
||||
run_shell_command "man echo"
|
||||
|
||||
new_tmux_window
|
||||
|
||||
# session yellow
|
||||
new_tmux_session "yellow"
|
||||
run_shell_command "mkdir bar"
|
||||
run_shell_command "cd bar"
|
||||
|
||||
start_resurrect_save
|
||||
|
||||
run_shell_command "tmux kill-server"
|
55
tests/helpers/expect_helpers.exp
Normal file
55
tests/helpers/expect_helpers.exp
Normal file
@ -0,0 +1,55 @@
|
||||
# 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 new_tmux_window {} {
|
||||
send "c"
|
||||
send "cd /tmp\r"
|
||||
sleep 0.2
|
||||
}
|
||||
|
||||
proc rename_current_session {name} {
|
||||
send "$"
|
||||
# delete existing name with ctrl-u
|
||||
send ""
|
||||
send "$name\r"
|
||||
sleep 0.2
|
||||
}
|
||||
|
||||
proc new_tmux_session {name} {
|
||||
send "TMUX='' tmux new -d -s $name\r"
|
||||
sleep 1
|
||||
send "tmux switch-client -t $name\r"
|
||||
send "cd /tmp\r"
|
||||
sleep 0.5
|
||||
}
|
||||
|
||||
proc horizontal_split {} {
|
||||
send "\""
|
||||
sleep 0.2
|
||||
send "cd /tmp\r"
|
||||
sleep 0.1
|
||||
}
|
||||
|
||||
proc vertical_split {} {
|
||||
send "%"
|
||||
sleep 0.2
|
||||
send "cd /tmp\r"
|
||||
sleep 0.1
|
||||
}
|
||||
|
||||
proc run_shell_command {command} {
|
||||
send "$command\r"
|
||||
sleep 1
|
||||
}
|
||||
|
||||
proc start_resurrect_save {} {
|
||||
send ""
|
||||
sleep 5
|
||||
}
|
12
tests/helpers/resurrect_helpers.sh
Normal file
12
tests/helpers/resurrect_helpers.sh
Normal file
@ -0,0 +1,12 @@
|
||||
install_tmux_resurrect_helper() {
|
||||
rm -rf ~/.tmux/plugins/tmux-resurrect/
|
||||
cd "$CURRENT_DIR"
|
||||
git clone --recursive ../ ~/.tmux/plugins/tmux-resurrect/ >/dev/null 2>&1
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
# we want "fixed" dimensions no matter the size of real display
|
||||
set_screen_dimensions() {
|
||||
stty cols 200
|
||||
stty rows 50
|
||||
}
|
31
tests/test_resurrect_save.sh
Executable file
31
tests/test_resurrect_save.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source $CURRENT_DIR/helpers/helpers.sh
|
||||
source $CURRENT_DIR/helpers/resurrect_helpers.sh
|
||||
|
||||
create_tmux_test_environment_and_save() {
|
||||
set_tmux_conf_helper<<-HERE
|
||||
run-shell '~/.tmux/plugins/tmux-resurrect/resurrect.tmux'
|
||||
HERE
|
||||
|
||||
set_screen_dimensions
|
||||
$CURRENT_DIR/helpers/create_and_save_tmux_test_environment.exp
|
||||
}
|
||||
|
||||
last_save_file_incorrect() {
|
||||
diff tests/fixtures/save_file.txt "${HOME}/.tmux/resurrect/last"
|
||||
[ $? -ne 0 ]
|
||||
}
|
||||
|
||||
main() {
|
||||
install_tmux_resurrect_helper
|
||||
create_tmux_test_environment_and_save
|
||||
if last_save_file_incorrect; then
|
||||
fail_helper "Saved file not correct"
|
||||
exit_helper
|
||||
fi
|
||||
exit_helper
|
||||
}
|
||||
main
|
Loading…
Reference in New Issue
Block a user