Add regression test for sk crash on pasting certain input

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2023-11-28 08:01:36 +01:00
parent 130c0b45c3
commit 959927aecf
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,59 @@
#!/usr/bin/expect -f
set basedir [file dirname $argv0]
set basename [file tail $argv0]
exp_internal -f $env(CLICKHOUSE_TMP)/$basename.debuglog 0
set history_file $env(CLICKHOUSE_TMP)/$basename.history
log_user 0
set timeout 60
match_max 100000
expect_after {
# Do not ignore eof from expect
-i $any_spawn_id eof { exp_continue }
# A default timeout action is to do nothing, change it to fail
-i $any_spawn_id timeout { exit 1 }
}
spawn bash -c "source $basedir/../shell_config.sh ; \$CLICKHOUSE_CLIENT_BINARY \$CLICKHOUSE_CLIENT_OPT --disable_suggestion --history_file=$history_file"
expect ":) "
# send Ctrl-R (octal code of R is 022, see ascii(7))
send -- "\022"
# we cannot use "expect" for skim, since it dups the fd, and expect will not catch it
sleep 1
# trigger a crash https://github.com/lotabout/tuikit/pull/51 via "pasting" "R;"
send -- "\33\[200~R;\33\[201~"
# usually this should be enough
sleep 1
# only panic info is written to regular stderr, so we are checking that it is not there
set is_panicked 0
set max_iterations 3
set timeout 1
while {$is_panicked == 0 && $max_iterations >= 0} {
expect {
"panic" {
set is_panicked 1
}
default {
# Reset the expect_after
}
}
set max_iterations [expr $max_iterations-1];
}
if {$is_panicked} {
send_user "Panicked\n"
exit 1
}
set timeout 60
# Ctrl-C
send -- "\3"
expect ":)"
send "exit\r"
expect eof