diff --git a/stmt/stmt.go b/stmt/stmt.go index 2cea5efc2c..7957543e45 100644 --- a/stmt/stmt.go +++ b/stmt/stmt.go @@ -228,6 +228,7 @@ parse: z, ok, _ := unquote(v.Name, true) if v.Defined = ok || v.Quote == '?'; v.Defined { b.r, b.rlen = v.Substitute(b.r, z, ok) + i-- // account for removal of the : } if b.Len != 0 { v.I += b.Len + 1 diff --git a/testcli.go b/testcli.go index 6900afa24d..604ad5d6c0 100644 --- a/testcli.go +++ b/testcli.go @@ -12,6 +12,7 @@ import ( "log" "os" "regexp" + "strings" "time" gexpect "github.com/google/goexpect" @@ -127,9 +128,17 @@ func (test Test) do(ctx context.Context, binpath string, timeout time.Duration) return err } for _, line := range bytes.Split(buf, []byte{'\n'}) { + // give time to usql to react to sent commands so statements are close to their results in output + // this helps link failures to the statement that caused them + time.Sleep(100 * time.Millisecond) if err := exp.Send(string(line) + "\n"); err != nil { return err } + if strings.TrimSpace(string(line)) == "\\q" { + break + // don't send any lines after quit command e.g. trailing empty lines + // Send() fails if the command has stopped + } } select { case <-ctx.Done():