mirror of
https://github.com/go-task/task.git
synced 2025-01-08 04:04:08 +02:00
fix: task level vars are not ignored in requires (#1960)
Co-authored-by: MOKEKO <Anthurium.1605@gmail.com>
This commit is contained in:
parent
8ce9bdc8c7
commit
da40aabcc7
@ -203,6 +203,9 @@ func TestRequires(t *testing.T) {
|
||||
require.NoError(t, e.Setup())
|
||||
require.ErrorContains(t, e.Run(context.Background(), &ast.Call{Task: "require-before-compile"}), "task: Task \"require-before-compile\" cancelled because it is missing required variables: MY_VAR")
|
||||
buff.Reset()
|
||||
|
||||
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "var-defined-in-task"}))
|
||||
buff.Reset()
|
||||
}
|
||||
|
||||
func TestSpecialVars(t *testing.T) {
|
||||
@ -1671,6 +1674,7 @@ func TestIncludesInterpolation(t *testing.T) { // nolint:paralleltest // cannot
|
||||
|
||||
func TestIncludesWithExclude(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var buff bytes.Buffer
|
||||
e := task.Executor{
|
||||
Dir: "testdata/includes_with_excludes",
|
||||
|
8
testdata/requires/Taskfile.yml
vendored
8
testdata/requires/Taskfile.yml
vendored
@ -10,6 +10,14 @@ tasks:
|
||||
- foo
|
||||
cmd: echo "{{.foo}}"
|
||||
|
||||
var-defined-in-task:
|
||||
vars:
|
||||
FOO: bar
|
||||
requires:
|
||||
vars:
|
||||
- FOO
|
||||
cmd: echo "{{.FOO}}"
|
||||
|
||||
|
||||
validation-var:
|
||||
requires:
|
||||
|
@ -56,7 +56,7 @@ func (e *Executor) compiledTask(call *ast.Call, evaluateShVars bool) (*ast.Task,
|
||||
Dir: templater.Replace(origTask.Dir, cache),
|
||||
Set: origTask.Set,
|
||||
Shopt: origTask.Shopt,
|
||||
Vars: nil,
|
||||
Vars: vars,
|
||||
Env: nil,
|
||||
Dotenv: templater.Replace(origTask.Dotenv, cache),
|
||||
Silent: origTask.Silent,
|
||||
|
Loading…
Reference in New Issue
Block a user