Skip to content

Commit

Permalink
Fix substitution of quoted variables
Browse files Browse the repository at this point in the history
testcli.go failed before the fix and passes after it.
Also includes a fix to testcli.go itself.
  • Loading branch information
murfffi committed Dec 17, 2024
1 parent e0e0807 commit 066926f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions stmt/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions testcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"log"
"os"
"regexp"
"strings"
"time"

gexpect "github.com/google/goexpect"
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 066926f

Please sign in to comment.