Skip to content

Commit 5dd9645

Browse files
committed
Use global sleepers to make test easier to control
1 parent e117325 commit 5dd9645

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed

test/helpers/expect_helpers.exp

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ proc exit_status_false {} {
1313
set exit_status 1
1414
}
1515

16+
proc sync_tmux {} {
17+
sleep 1.0
18+
}
19+
20+
proc sync_irb {} {
21+
sleep 5.0
22+
}
23+
1624
proc teardown_and_exit {} {
1725
global exit_status
1826
_kill_tmux_server
@@ -25,84 +33,84 @@ proc create_output {} {
2533
sleep 0.1
2634
# stop `yes` command
2735
send ""
28-
sleep 0.1
36+
sync_tmux
2937
}
3038

3139
proc clear_screen {} {
3240
send " "
33-
sleep 0.1
41+
sync_tmux
3442
}
3543

3644
proc display_text {text} {
3745
send "echo $text\r"
38-
sleep 0.3
46+
sync_tmux
3947
}
4048

4149
proc new_tmux_pane {} {
4250
sleep 0.3
4351
send "c"
44-
sleep 1
52+
sleep 1.0
4553
}
4654

4755
proc enter_irb {} {
4856
send "irb\r"
49-
sleep 1
57+
sync_irb
5058
}
5159

5260
proc exit_irb {} {
5361
send "\r"
54-
sleep 0.1
62+
sync_irb
5563
send "exit\r"
56-
sleep 0.5
64+
sync_tmux
5765
}
5866

5967
proc irb_display_text {text} {
6068
send "puts '$text'\r"
61-
sleep 5.0
69+
sync_irb
6270
}
6371

6472
# Generates random output just to fill the screen.
6573
proc irb_generate_output {} {
6674
send "puts 'output\n' * 200\r"
67-
sleep 5.0
75+
sync_irb
6876
}
6977

7078
proc enter_test_git_repo {} {
71-
sleep 0.2
79+
sync_tmux
7280
send "cd ~/tmux-example-plugin\r"
73-
sleep 0.1
81+
sync_tmux
7482
send "git checkout --quiet tags/v0.0.1\r"
75-
sleep 0.2
83+
sync_tmux
7684
}
7785

7886
proc git_status {} {
79-
sleep 0.1
87+
sync_tmux
8088
send "git status --short\r"
81-
sleep 0.1
89+
sync_tmux
8290
}
8391

8492
proc git_log_reverse_short {} {
85-
sleep 0.1
93+
sync_tmux
8694
send "git --no-pager log --reverse --oneline -1\r"
87-
sleep 0.1
95+
sync_tmux
8896
}
8997

9098
proc git_log_reverse {} {
91-
sleep 0.1
99+
sync_tmux
92100
send "git --no-pager log --reverse -1\r"
93-
sleep 0.1
101+
sync_tmux
94102
}
95103

96104
proc git_checkout {} {
97-
sleep 0.1
105+
sync_tmux
98106
send "git checkout -- .\r"
99-
sleep 0.1
107+
sync_tmux
100108
}
101109

102110
proc git_clean_fd {} {
103-
sleep 0.1
111+
sync_tmux
104112
send "git clean -f -d\r"
105-
sleep 0.1
113+
sync_tmux
106114
}
107115

108116
proc clean_git_repo {} {
@@ -111,30 +119,31 @@ proc clean_git_repo {} {
111119
}
112120

113121
proc change_file {file} {
114-
sleep 0.1
122+
sync_tmux
115123
send "echo 'change' > $file\r"
116-
sleep 0.1
124+
sync_tmux
117125
}
118126

119127
proc create_new_file_in_repo {} {
120-
sleep 0.1
128+
sync_tmux
121129
send "echo 'text' >> new_file.txt\r"
122-
sleep 0.1
130+
sync_tmux
123131
}
124132

125133
proc remove_test_git_repo {} {
126-
sleep 0.1
134+
sync_tmux
127135
send "cd ~\r"
128-
sleep 0.1
136+
sync_tmux
129137
send "rm -rf ~/tmux_example_plugin/\r"
130-
sleep 0.1
138+
sync_tmux
131139
}
132140

133141
# private functions
134142

135143
proc _kill_tmux_server {} {
136144
send ""
137-
sleep 0.1
145+
sync_tmux
138146
send "tmux kill-server\r"
139-
sleep 0.2
147+
sync_tmux
140148
}
149+

test/test_digit_search.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ assert_highlighted "345" "middle of the pane, not beginning of the line"
2323

2424
create_output
2525
send "456"
26-
sleep 0.1
26+
sync_tmux
2727
tmux_ctrl_d
2828
assert_highlighted "456" "middle of the pane, pane bottom"
2929

@@ -121,7 +121,7 @@ exit_irb
121121
enter_irb
122122
irb_generate_output
123123
send "puts 012"
124-
sleep 5.0
124+
sync_tmux
125125
tmux_ctrl_d
126126
irb_assert_highlighted "012" "irb console, pane bottom, not beggining of line"
127127
exit_irb

0 commit comments

Comments
 (0)