github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cli/interactive_tests/test_history.tcl (about) 1 #! /usr/bin/env expect -f 2 3 source [file join [file dirname $argv0] common.tcl] 4 5 start_server $argv 6 7 spawn $argv sql 8 eexpect root@ 9 10 # Ensure the connection is up and working. 11 send "select 1;\r" 12 eexpect "1 row" 13 eexpect root@ 14 15 start_test "Test that last line can be recalled with arrow-up" 16 send "\033\[A" 17 eexpect "select 1;" 18 end_test 19 20 start_test "Test that recalled last line can be executed" 21 send "\r" 22 eexpect "1 row" 23 eexpect root@ 24 end_test 25 26 start_test "Test that we can recall a previous line with Ctrl+R" 27 send "foo;\r" 28 eexpect "syntax error" 29 eexpect root@ 30 send "\022sel" 31 eexpect "select 1;" 32 end_test 33 34 start_test "Test that recalled previous line can be executed" 35 send "\r" 36 eexpect "1 row" 37 eexpect root@ 38 end_test 39 40 start_test "Test that last recalled line becomes top of history" 41 send "\033\[A" 42 eexpect "select 1;" 43 end_test 44 45 start_test "Test that client cannot terminate with Ctrl+D while cursor is on recalled line" 46 send_eof 47 send "\r" 48 eexpect "1 row" 49 eexpect root@ 50 end_test 51 52 start_test "Test that Ctrl+D does terminate client on empty line" 53 send_eof 54 eexpect eof 55 end_test 56 57 start_test "Test that history is preserved across runs" 58 spawn $argv sql 59 eexpect root@ 60 send "\033\[A" 61 eexpect "select 1;" 62 end_test 63 64 start_test "Test that the client cannot terminate with Ctrl+C while cursor is on recalled line" 65 interrupt 66 send "\rselect 1;\r" 67 eexpect "1 row" 68 eexpect root@ 69 end_test 70 71 start_test "Test that two statements on the same line can be recalled together." 72 send "select 2; select 3;\r" 73 eexpect "1 row" 74 eexpect "1 row" 75 eexpect root@ 76 send "\033\[A" 77 eexpect "select 2; select 3;" 78 send "\r" 79 eexpect "1 row" 80 eexpect "1 row" 81 eexpect root@ 82 end_test 83 84 # Finally terminate with Ctrl+C 85 interrupt 86 eexpect eof 87 88 stop_server $argv