Skip to content

Commit

Permalink
fqtest: No need to escape empty stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 12, 2021
1 parent e2ff2a2 commit dee10db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 5 additions & 3 deletions pkg/fqtest/fqtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ func (tc *testCase) ToActual() string {
case *testCaseRun:
fmt.Fprintf(sb, "$%s\n", p.args)
s := p.actualStdoutBuf.String()
fmt.Fprint(sb, s)
if !strings.HasSuffix(s, "\n") {
fmt.Fprint(sb, "\\\n")
if s != "" {
fmt.Fprint(sb, s)
if !strings.HasSuffix(s, "\n") {
fmt.Fprint(sb, "\\\n")
}
}
if p.actualExitCode != 0 {
fmt.Fprintf(sb, "exitcode: %d\n", p.actualExitCode)
Expand Down
5 changes: 0 additions & 5 deletions pkg/interp/testdata/args.fqtest
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/test.mp3:
$ fq
\
exitcode: 2
stderr:
Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
Expand Down Expand Up @@ -50,7 +49,6 @@ null> ^D
$ fq -i . /test.mp3
mp3> ^D
$ fq -n
\
exitcode: 2
stderr:
Usage: fq [OPTIONS] [--] [EXPR] [FILE...]
Expand Down Expand Up @@ -131,17 +129,14 @@ wav WAV file
webp WebP image
xing Xing header
$ fq -X
\
exitcode: 2
stderr:
error: -X: no such argument
$ fq --X
\
exitcode: 2
stderr:
error: --X: no such argument
$ fq -.
\
exitcode: 2
stderr:
error: -.: no such argument

0 comments on commit dee10db

Please sign in to comment.