mirror of
https://github.com/go-task/task.git
synced 2026-02-24 20:20:30 +01:00
test(scoped-includes): add tests for variable isolation
Tests verify: - Legacy mode: vars merged globally (A sees B's VAR, can access UNIQUE_B) - Scoped mode: vars isolated (A sees own VAR, cannot access UNIQUE_B) - Inheritance: includes can still access root vars (ROOT_VAR) Test structure: - testdata/scoped_includes/ with main Taskfile and two includes - inc_a and inc_b both define VAR with different values - Cross-include test shows A trying to access B's UNIQUE_B
This commit is contained in:
20
testdata/scoped_includes/Taskfile.yml
vendored
Normal file
20
testdata/scoped_includes/Taskfile.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
ROOT_VAR: from_root
|
||||
|
||||
includes:
|
||||
a: ./inc_a
|
||||
b: ./inc_b
|
||||
|
||||
tasks:
|
||||
default:
|
||||
desc: Test scoped includes - vars should be isolated
|
||||
cmds:
|
||||
- task: a:print
|
||||
- task: b:print
|
||||
|
||||
print-root-var:
|
||||
desc: Print ROOT_VAR from root
|
||||
cmds:
|
||||
- echo "ROOT_VAR={{.ROOT_VAR}}"
|
||||
18
testdata/scoped_includes/inc_a/Taskfile.yml
vendored
Normal file
18
testdata/scoped_includes/inc_a/Taskfile.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
VAR: value_from_a
|
||||
UNIQUE_A: only_in_a
|
||||
|
||||
tasks:
|
||||
print:
|
||||
desc: Print vars from include A
|
||||
cmds:
|
||||
- echo "A:VAR={{.VAR}}"
|
||||
- echo "A:UNIQUE_A={{.UNIQUE_A}}"
|
||||
- echo "A:ROOT_VAR={{.ROOT_VAR}}"
|
||||
|
||||
try-access-b:
|
||||
desc: Try to access B's unique var (should fail in scoped mode)
|
||||
cmds:
|
||||
- echo "A:UNIQUE_B={{.UNIQUE_B}}"
|
||||
13
testdata/scoped_includes/inc_b/Taskfile.yml
vendored
Normal file
13
testdata/scoped_includes/inc_b/Taskfile.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
VAR: value_from_b
|
||||
UNIQUE_B: only_in_b
|
||||
|
||||
tasks:
|
||||
print:
|
||||
desc: Print vars from include B
|
||||
cmds:
|
||||
- echo "B:VAR={{.VAR}}"
|
||||
- echo "B:UNIQUE_B={{.UNIQUE_B}}"
|
||||
- echo "B:ROOT_VAR={{.ROOT_VAR}}"
|
||||
1
testdata/scoped_includes/testdata/TestScopedIncludes-legacy-cross-include.golden
vendored
Normal file
1
testdata/scoped_includes/testdata/TestScopedIncludes-legacy-cross-include.golden
vendored
Normal file
@@ -0,0 +1 @@
|
||||
A:UNIQUE_B=only_in_b
|
||||
6
testdata/scoped_includes/testdata/TestScopedIncludes-legacy-default.golden
vendored
Normal file
6
testdata/scoped_includes/testdata/TestScopedIncludes-legacy-default.golden
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
A:VAR=value_from_b
|
||||
A:UNIQUE_A=only_in_a
|
||||
A:ROOT_VAR=from_root
|
||||
B:VAR=value_from_b
|
||||
B:UNIQUE_B=only_in_b
|
||||
B:ROOT_VAR=from_root
|
||||
1
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-cross-include.golden
vendored
Normal file
1
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-cross-include.golden
vendored
Normal file
@@ -0,0 +1 @@
|
||||
A:UNIQUE_B=
|
||||
6
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-default.golden
vendored
Normal file
6
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-default.golden
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
A:VAR=value_from_a
|
||||
A:UNIQUE_A=only_in_a
|
||||
A:ROOT_VAR=from_root
|
||||
B:VAR=value_from_b
|
||||
B:UNIQUE_B=only_in_b
|
||||
B:ROOT_VAR=from_root
|
||||
3
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-inheritance-a.golden
vendored
Normal file
3
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-inheritance-a.golden
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
A:VAR=value_from_a
|
||||
A:UNIQUE_A=only_in_a
|
||||
A:ROOT_VAR=from_root
|
||||
3
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-isolation-b.golden
vendored
Normal file
3
testdata/scoped_includes/testdata/TestScopedIncludes-scoped-isolation-b.golden
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
B:VAR=value_from_b
|
||||
B:UNIQUE_B=only_in_b
|
||||
B:ROOT_VAR=from_root
|
||||
Reference in New Issue
Block a user