Skip to content

Commit 2501edf

Browse files
committed
fix: Ensure that task labels are used in error messages when present
1 parent 7ca502e commit 2501edf

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

executor_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,15 @@ func TestLabel(t *testing.T) {
665665
),
666666
WithTask("foo"),
667667
)
668+
669+
NewExecutorTest(t,
670+
WithName("label in error"),
671+
WithExecutorOptions(
672+
task.WithDir("testdata/label_error"),
673+
),
674+
WithTask("foo"),
675+
WithRunError(),
676+
)
668677
}
669678

670679
func TestPromptInSummary(t *testing.T) {

task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (e *Executor) RunTask(ctx context.Context, call *Call) error {
235235
e.Logger.VerboseErrf(logger.Magenta, "task: %q finished\n", call.Task)
236236
return nil
237237
}); err != nil {
238-
return &errors.TaskRunError{TaskName: t.Task, Err: err}
238+
return &errors.TaskRunError{TaskName: t.Name(), Err: err}
239239
}
240240

241241
return nil

testdata/label_error/Taskfile.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3'
2+
3+
tasks:
4+
foo:
5+
label: "foobar"
6+
cmds:
7+
- "false"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
task: Failed to run task "foobar": exit status 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
task: [foobar] false

0 commit comments

Comments
 (0)