diff --git a/pkg/cli/interactive_tests/common.tcl b/pkg/cli/interactive_tests/common.tcl index bc50d6d7d05d..9ef881f5a044 100644 --- a/pkg/cli/interactive_tests/common.tcl +++ b/pkg/cli/interactive_tests/common.tcl @@ -69,6 +69,15 @@ proc eexpect {text} { } } +# eexpect_re is like eexpect, but takes a regular expression argument +# instead of a text string +proc eexpect_re {text} { + expect { + -re $text {} + timeout { handle_timeout $text } + } +} + # Convenience function that sends Ctrl+C to the monitored process. proc interrupt {} { report "INTERRUPT TO FOREGROUND PROCESS" @@ -178,4 +187,3 @@ proc stop_tenant {tenant_id argv} { report "END STOP TENANT $tenant_id" } - diff --git a/pkg/cli/interactive_tests/test_txn_prompt.tcl b/pkg/cli/interactive_tests/test_txn_prompt.tcl old mode 100644 new mode 100755 index a74a18ab89c8..389b86902386 --- a/pkg/cli/interactive_tests/test_txn_prompt.tcl +++ b/pkg/cli/interactive_tests/test_txn_prompt.tcl @@ -43,7 +43,11 @@ eexpect abcdefaultdbdef # Check prompt with no formatting code. send "\\set prompt1 woo \r" -eexpect woo +# use a regular expression to match the `woo` prompt (beginning of +# line). If we use `eexpect` here, the match would happen +# instantaneously as it would match the previous `set prompt1 woo` +# command, as it also contains the string `woo`. +eexpect_re "(?n)^woo $" send "SET database \r" eexpect "\r\n -> "