Skip to content

Commit

Permalink
Revert "tools/flow: check and return errors from task values"
Browse files Browse the repository at this point in the history
This reverts commit 9ef35eb
but keeps the `cmd_undefined` test case and updates
the `issue2517` test case so that it illustrates the way that
the reverted commit fails.

That commit introduced a regression that caused existing
tools/flow uses to fail. See https://cuelang.org/issue/2965.

A subsequent CL will apply a different fix for #1581.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I322ac3b269bc79a541c15001a166160ad9191267
  • Loading branch information
rogpeppe committed Mar 20, 2024
1 parent 50ed912 commit 60757af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
21 changes: 15 additions & 6 deletions cmd/cue/cmd/testdata/script/cmd_undefined.txtar
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
! exec cue cmd tool
stderr 'command.tool.bad: undefined field: DoesntExist'
! exec cue cmd builtin
stderr 'command.builtin.bad: undefined field: DoesntExist'
! exec cue cmd package
stderr 'command.package.bad: undefined field: DoesntExist'
# This test illustrates the problem demonstrated
# in https://github.com/cue-lang/cue/issues/1581
# TODO fix tools/flow so it fails in this case.

# TODO this should not succeed
exec cue cmd tool
# stderr 'command.tool.bad: undefined field: DoesntExist'

# TODO this should not succeed
exec cue cmd builtin
# stderr 'command.builtin.bad: undefined field: DoesntExist'

# TODO this should not succeed
exec cue cmd package
# stderr 'command.package.bad: undefined field: DoesntExist'
-- cue.mod/module.cue --
module: "mod.test/test"
-- sub/sub.cue --
Expand Down
4 changes: 0 additions & 4 deletions tools/flow/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ func (c *Controller) findRootTasks(v cue.Value) {

// getTask finds and marks tasks that are descendents of v.
func (c *Controller) getTask(scope *Task, v cue.Value) *Task {
if err := v.Err(); err != nil {
c.addErr(err, "invalid task")
return nil
}
// Look up cached node.
_, w := value.ToInternal(v)
if t, ok := c.nodes[w]; ok {
Expand Down
7 changes: 3 additions & 4 deletions tools/flow/testdata/issue2517.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package x
root: {
prepare: {
$id: "prepare"
stdout: string
}
env2: {
input: prepare.stdout
Expand Down Expand Up @@ -42,7 +41,7 @@ Allocs: 5
Retain: 0

Unifications: 11
Conjuncts: 20
Conjuncts: 17
Disjuncts: 11
-- out/run/t2 --
graph TD
Expand All @@ -66,7 +65,7 @@ Allocs: 0
Retain: 0

Unifications: 12
Conjuncts: 24
Conjuncts: 21
Disjuncts: 12
-- out/run/stats/totals --
Leaks: 0
Expand All @@ -76,5 +75,5 @@ Allocs: 5
Retain: 0

Unifications: 23
Conjuncts: 44
Conjuncts: 38
Disjuncts: 23

0 comments on commit 60757af

Please sign in to comment.