1
0
mirror of https://github.com/go-task/task.git synced 2025-06-02 23:27:37 +02:00

Change error output

This commit is contained in:
Stephen Prater 2019-06-11 12:20:56 -07:00
parent d1463b3e24
commit cc9264854e
3 changed files with 5 additions and 9 deletions

View File

@ -22,7 +22,7 @@ func (e *Executor) areTaskPreconditionsMet(ctx context.Context, t *taskfile.Task
}) })
if err != nil { if err != nil {
e.Logger.Outf("task: %s", p.Msg) e.Logger.Errf("task: %s", p.Msg)
return false, ErrPreconditionFailed return false, ErrPreconditionFailed
} }
} }

View File

@ -293,7 +293,7 @@ func TestPrecondition(t *testing.T) {
// A precondition that was not met // A precondition that was not met
assert.Error(t, e.Run(context.Background(), taskfile.Call{Task: "impossible"})) assert.Error(t, e.Run(context.Background(), taskfile.Call{Task: "impossible"}))
if buff.String() != "1 != 0\n" { if buff.String() != "task: 1 != 0 obviously!\n" {
t.Errorf("Wrong output message: %s", buff.String()) t.Errorf("Wrong output message: %s", buff.String())
} }
buff.Reset() buff.Reset()
@ -301,14 +301,14 @@ func TestPrecondition(t *testing.T) {
// Calling a task with a precondition in a dependency fails the task // Calling a task with a precondition in a dependency fails the task
assert.Error(t, e.Run(context.Background(), taskfile.Call{Task: "depends_on_imposssible"})) assert.Error(t, e.Run(context.Background(), taskfile.Call{Task: "depends_on_imposssible"}))
if buff.String() != "1 != 0\ntask: precondition not met\n" { if buff.String() != "task: 1 != 0 obviously!\n" {
t.Errorf("Wrong output message: %s", buff.String()) t.Errorf("Wrong output message: %s", buff.String())
} }
buff.Reset() buff.Reset()
// Calling a task with a precondition in a cmd fails the task // Calling a task with a precondition in a cmd fails the task
assert.Error(t, e.Run(context.Background(), taskfile.Call{Task: "executes_failing_task_as_cmd"})) assert.Error(t, e.Run(context.Background(), taskfile.Call{Task: "executes_failing_task_as_cmd"}))
if buff.String() != "1 != 0\ntask: precondition not met\n" { if buff.String() != "task: 1 != 0 obviously!\n" {
t.Errorf("Wrong output message: %s", buff.String()) t.Errorf("Wrong output message: %s", buff.String())
} }
buff.Reset() buff.Reset()

View File

@ -8,7 +8,7 @@ tasks:
impossible: impossible:
preconditions: preconditions:
- sh: "[ 1 = 0 ]" - sh: "[ 1 = 0 ]"
msg: "1 != 0" msg: "1 != 0 obviously!"
depends_on_imposssible: depends_on_imposssible:
deps: deps:
@ -17,7 +17,3 @@ tasks:
executes_failing_task_as_cmd: executes_failing_task_as_cmd:
cmds: cmds:
- task: impossible - task: impossible
depends_on_failure_of_impossible:
deps:
- impossible_but_i_dont_care