Skip to content

Commit

Permalink
cmd/cue: test tool/exec.Run with arguments involving spaces
Browse files Browse the repository at this point in the history
The command is expected to fail, as we run the "false" program
which always fails and ignores any arguments.

The printed error is ambiguous, as it's not possible to see
what the original list of arguments was, hence the TODO.
The following commit will resolve this bug.

For #3238.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: Ie277772ce58dfac48df9440e0a53fd9f1fc309cc
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1197451
Reviewed-by: Roger Peppe <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mvdan committed Jul 9, 2024
1 parent 95802d3 commit 5903ec8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/cue/cmd/testdata/script/cmd_errcode.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ command: errcode: {
kind: "exec"
cmd: "ls --badflags"
stderr: string // suppress error message
}}
}
}
11 changes: 11 additions & 0 deletions cmd/cue/cmd/testdata/script/cmd_execerr.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ cmp stderr cannotFail-stderr.golden
exec cue cmd canFail
cmp stdout canFail-stdout.golden

# TODO(mvdan): the error message should quote the argument list
# so that any arguments with spaces do not introduce ambiguity.
! exec cue cmd withSpaces
cmp stderr withSpaces-stderr.golden

-- cue.mod/module.cue --
module: "example.com"
language: version: "v0.9.0"
Expand All @@ -18,6 +23,8 @@ hasStderr=false
errNotFound:
success=false
hasStderr=true
-- withSpaces-stderr.golden --
task failed: command "false with an ignored argument" failed: exit status 1
-- foo_tool.cue --
package foo

Expand Down Expand Up @@ -55,3 +62,7 @@ command: canFail: {
"""
}
}

command: withSpaces: exec.Run & {
cmd: ["false", "with an ignored argument"]
}

0 comments on commit 5903ec8

Please sign in to comment.