github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cli/interactive_tests/test_error_handling.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 /bin/bash 8 send "PS1=':''/# '\r" 9 eexpect ":/# " 10 11 start_test "Check that by default, an error prevents subsequent statements from running." 12 send "(echo 'select foo;'; echo 'select 1;') | $argv sql\r" 13 eexpect "ERROR: column \"foo\" does not exist" 14 eexpect ":/# " 15 send "echo \$?\r" 16 eexpect "1\r\n:/# " 17 end_test 18 19 start_test "Check that a user can request to continue upon failures." 20 send "(echo '\\unset errexit'; echo 'select foo;'; echo 'select 1;') | $argv sql\r" 21 eexpect "ERROR: column \"foo\" does not exist" 22 eexpect "1 row" 23 eexpect ":/# " 24 send "echo \$?\r" 25 eexpect "0\r\n:/# " 26 27 send "$argv sql\r" 28 eexpect "root@" 29 end_test 30 31 start_test "Check that by default, an error does not cause an interactive failure." 32 send "select foo;\r" 33 eexpect "ERROR: column \"foo\" does not exist" 34 eexpect "root@" 35 end_test 36 37 start_test "Check that the user can ask for errors to terminate the interactive client." 38 send "\\set errexit\r" 39 eexpect "root@" 40 send "select foo;\r" 41 eexpect "ERROR: column \"foo\" does not exist" 42 eexpect ":/# " 43 send "echo \$?\r" 44 eexpect "1\r\n:/# " 45 end_test 46 47 start_test "Check that unknown sub-commands report a non-zero exit status." 48 send "$argv node wowowo\r" 49 eexpect "ERROR: unknown sub-command" 50 eexpect ":/# " 51 send "echo \$?\r" 52 eexpect "1\r\n:/# " 53 end_test 54 55 send "exit 0\r" 56 eexpect eof 57 58 stop_server $argv