diff --git a/internal/goext/meta.go b/internal/goext/meta.go index 24c53d0d6b..297c69ef21 100644 --- a/internal/goext/meta.go +++ b/internal/goext/meta.go @@ -32,6 +32,7 @@ var knownOS = map[string]struct{}{ "solaris": {}, "windows": {}, "zos": {}, + "__test__": {}, } var knownArch = map[string]struct{}{ diff --git a/task.go b/task.go index efed681e4d..c646df8a06 100644 --- a/task.go +++ b/task.go @@ -160,7 +160,16 @@ func (e *Executor) splitRegularAndWatchCalls(calls ...taskfile.Call) (regularCal // RunTask runs a task by its name func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error { - t, err := e.CompiledTask(call) + t, err := e.FastCompiledTask(call) + if err != nil { + return err + } + if !shouldRunOnCurrentPlatform(t.Platforms) { + e.Logger.VerboseOutf(logger.Yellow, `task: %q not for current platform - ignored\n`, call.Task) + return nil + } + + t, err = e.CompiledTask(call) if err != nil { return err } @@ -185,11 +194,6 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error { } return e.startExecution(ctx, t, func(ctx context.Context) error { - if !shouldRunOnCurrentPlatform(t.Platforms) { - e.Logger.VerboseOutf(logger.Yellow, `task: %q not for current platform - ignored\n`, call.Task) - return nil - } - e.Logger.VerboseErrf(logger.Magenta, "task: %q started\n", call.Task) if err := e.runDeps(ctx, t); err != nil { return err diff --git a/testdata/platforms/Taskfile.yml b/testdata/platforms/Taskfile.yml index c25e244c4c..354379b79e 100644 --- a/testdata/platforms/Taskfile.yml +++ b/testdata/platforms/Taskfile.yml @@ -2,31 +2,37 @@ version: '3' tasks: build-windows: + deps: [failed-var-other-platform] platforms: [windows] cmds: - echo 'Running task on windows' build-darwin: + deps: [failed-var-other-platform] platforms: [darwin] cmds: - echo 'Running task on darwin' build-linux: + deps: [failed-var-other-platform] platforms: [linux] cmds: - echo 'Running task on linux' build-freebsd: + deps: [failed-var-other-platform] platforms: [freebsd] cmds: - echo 'Running task on freebsd' build-blank-os: + deps: [failed-var-other-platform] platforms: [] cmds: - echo 'Running command' build-multiple: + deps: [failed-var-other-platform] platforms: [] cmds: - cmd: echo 'Running command' @@ -36,16 +42,19 @@ tasks: platforms: [darwin] build-amd64: + deps: [failed-var-other-platform] platforms: [amd64] cmds: - echo "Running command on amd64" build-arm64: + deps: [failed-var-other-platform] platforms: [arm64] cmds: - echo "Running command on arm64" build-mixed: + deps: [failed-var-other-platform] cmds: - cmd: echo 'building on windows/arm64' platforms: [windows/arm64] @@ -53,3 +62,10 @@ tasks: platforms: [linux/amd64] - cmd: echo 'building on darwin' platforms: [darwin] + + failed-var-other-platform: + platforms: [__test__] + env: + EXAMPLE_VAR: {sh: exit 1} + vars: + EXAMPLE_VAR: {sh: exit 2}