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 adds
a new test case (very similar to the test case for #2517)
that 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.

For #2965.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I322ac3b269bc79a541c15001a166160ad9191267
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1185281
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
(cherry picked from commit ea385fd)
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1190978
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
rogpeppe authored and mvdan committed Apr 3, 2024
1 parent 773ab2d commit 0630a37
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 10 deletions.
21 changes: 15 additions & 6 deletions cmd/cue/cmd/testdata/script/cmd_undefined.txtar
@@ -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
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
83 changes: 83 additions & 0 deletions tools/flow/testdata/issue2965.txtar
@@ -0,0 +1,83 @@
#IgnoreConcrete: true
#InferTasks: true
-- in.cue --
package x

root: {
prepare: {
$id: "prepare"
stdout: string
}
env2: {
// Note: the string interpolation here is the only difference
// from issue2517.txtar. It makes the value incomplete
// rather than just non-concrete.
input: "\(prepare.stdout)"
}
run: {
$id: "run"
env: env2
}
}
-- out/run/errors --
-- out/run/t0 --
graph TD
t0("root.prepare [Ready]")
t1("root.run [Waiting]")
t1-->t0

-- out/run/t1 --
graph TD
t0("root.prepare [Terminated]")
t1("root.run [Ready]")
t1-->t0

-- out/run/t1/value --
{
$id: "prepare"
stdout: "foo"
}
-- out/run/t1/stats --
Leaks: 0
Freed: 11
Reused: 6
Allocs: 5
Retain: 0

Unifications: 11
Conjuncts: 16
Disjuncts: 11
-- out/run/t2 --
graph TD
t0("root.prepare [Terminated]")
t1("root.run [Terminated]")
t1-->t0

-- out/run/t2/value --
{
$id: "run"
stdout: "foo"
env: {
input: "foo"
}
}
-- out/run/t2/stats --
Leaks: 0
Freed: 12
Reused: 12
Allocs: 0
Retain: 0

Unifications: 12
Conjuncts: 20
Disjuncts: 12
-- out/run/stats/totals --
Leaks: 0
Freed: 23
Reused: 18
Allocs: 5
Retain: 0

Unifications: 23
Conjuncts: 36
Disjuncts: 23

0 comments on commit 0630a37

Please sign in to comment.