Skip to content

Commit 066926f

Browse files
committed
Fix substitution of quoted variables
testcli.go failed before the fix and passes after it. Also includes a fix to testcli.go itself.
1 parent e0e0807 commit 066926f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

stmt/stmt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ parse:
228228
z, ok, _ := unquote(v.Name, true)
229229
if v.Defined = ok || v.Quote == '?'; v.Defined {
230230
b.r, b.rlen = v.Substitute(b.r, z, ok)
231+
i-- // account for removal of the :
231232
}
232233
if b.Len != 0 {
233234
v.I += b.Len + 1

testcli.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"log"
1313
"os"
1414
"regexp"
15+
"strings"
1516
"time"
1617

1718
gexpect "github.com/google/goexpect"
@@ -127,9 +128,17 @@ func (test Test) do(ctx context.Context, binpath string, timeout time.Duration)
127128
return err
128129
}
129130
for _, line := range bytes.Split(buf, []byte{'\n'}) {
131+
// give time to usql to react to sent commands so statements are close to their results in output
132+
// this helps link failures to the statement that caused them
133+
time.Sleep(100 * time.Millisecond)
130134
if err := exp.Send(string(line) + "\n"); err != nil {
131135
return err
132136
}
137+
if strings.TrimSpace(string(line)) == "\\q" {
138+
break
139+
// don't send any lines after quit command e.g. trailing empty lines
140+
// Send() fails if the command has stopped
141+
}
133142
}
134143
select {
135144
case <-ctx.Done():

0 commit comments

Comments
 (0)