diff --git a/executor_test.go b/executor_test.go index 6e3ff3e1ec..9e9bfe2c52 100644 --- a/executor_test.go +++ b/executor_test.go @@ -942,6 +942,32 @@ func TestReference(t *testing.T) { } } +func TestShVarWithIncludes(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + call string + }{ + { + name: "sh var not clobbered by includes", + call: "default", + }, + } + + for _, test := range tests { + NewExecutorTest(t, + WithName(test.name), + WithExecutorOptions( + task.WithDir("testdata/var_sh_with_includes"), + task.WithSilent(true), + task.WithForce(true), + ), + WithTask(cmp.Or(test.call, "default")), + ) + } +} + func TestVarInheritance(t *testing.T) { enableExperimentForTest(t, &experiments.EnvPrecedence, 1) tests := []struct { diff --git a/testdata/var_sh_with_includes/Included.yml b/testdata/var_sh_with_includes/Included.yml new file mode 100644 index 0000000000..9c0f4e437a --- /dev/null +++ b/testdata/var_sh_with_includes/Included.yml @@ -0,0 +1,6 @@ +version: '3' + +tasks: + noop: + cmds: + - "true" diff --git a/testdata/var_sh_with_includes/Taskfile.yml b/testdata/var_sh_with_includes/Taskfile.yml new file mode 100644 index 0000000000..7e3bf197dc --- /dev/null +++ b/testdata/var_sh_with_includes/Taskfile.yml @@ -0,0 +1,18 @@ +version: '3' + +includes: + other: + taskfile: ./Included.yml + internal: true + +vars: + DYNAMIC_VAR: + sh: echo "hello" + DERIVED_VAR: "{{.DYNAMIC_VAR}} world" + +tasks: + default: + cmds: + - echo "DYNAMIC_VAR={{.DYNAMIC_VAR}}" + - echo "DERIVED_VAR={{.DERIVED_VAR}}" + silent: true diff --git a/testdata/var_sh_with_includes/testdata/TestShVarWithIncludes-sh_var_not_clobbered_by_includes.golden b/testdata/var_sh_with_includes/testdata/TestShVarWithIncludes-sh_var_not_clobbered_by_includes.golden new file mode 100644 index 0000000000..066c073193 --- /dev/null +++ b/testdata/var_sh_with_includes/testdata/TestShVarWithIncludes-sh_var_not_clobbered_by_includes.golden @@ -0,0 +1,2 @@ +DYNAMIC_VAR=hello +DERIVED_VAR=hello world