refactor: unify how executor tests are written (#2042)

* feat: use TaskTest for executor tests

* feat: more tests

* feat: separate tests for executing and formatting with new functional options that work for both test types

* feat: formatter tests

* refactor: more tests
This commit is contained in:
Pete Davison
2025-03-31 17:53:58 +01:00
committed by GitHub
parent 180fcef364
commit 4736bc2734
175 changed files with 1706 additions and 1111 deletions

View File

@@ -1 +0,0 @@
*.txt

View File

@@ -28,13 +28,13 @@ tasks:
CGO_ENABLED:
sh: echo '0'
cmds:
- echo "GOOS='$GOOS' GOARCH='$GOARCH' CGO_ENABLED='$CGO_ENABLED'" > local.txt
- echo "GOOS='$GOOS' GOARCH='$GOARCH' CGO_ENABLED='$CGO_ENABLED'"
global:
env:
BAR: overridden
cmds:
- echo "FOO='$FOO' BAR='$BAR' BAZ='$BAZ'" > global.txt
- echo "FOO='$FOO' BAR='$BAR' BAZ='$BAZ'"
multiple_type:
env:
@@ -42,15 +42,15 @@ tasks:
BAR: true
BAZ: 1.1
cmds:
- echo "FOO='$FOO' BAR='$BAR' BAZ='$BAZ'" > multiple_type.txt
- echo "FOO='$FOO' BAR='$BAR' BAZ='$BAZ'"
not-overridden:
cmds:
- echo "QUX='$QUX'" > not-overridden.txt
- echo "QUX='$QUX'"
overridden:
cmds:
- echo "QUX='$QUX'" > overridden.txt
- echo "QUX='$QUX'"
dynamic:
silent: true
@@ -58,4 +58,4 @@ tasks:
DYNAMIC_FOO:
sh: echo $FOO
cmds:
- echo "{{ .DYNAMIC_FOO }}" > dynamic.txt
- echo "{{ .DYNAMIC_FOO }}"

1
testdata/env/dynamic.txt vendored Normal file
View File

@@ -0,0 +1 @@
foo

1
testdata/env/global.txt vendored Normal file
View File

@@ -0,0 +1 @@
FOO='foo' BAR='overridden' BAZ='baz'

1
testdata/env/local.txt vendored Normal file
View File

@@ -0,0 +1 @@
GOOS='linux' GOARCH='amd64' CGO_ENABLED='0'

1
testdata/env/multiple_type.txt vendored Normal file
View File

@@ -0,0 +1 @@
FOO='1' BAR='true' BAZ='1.1'

1
testdata/env/not-overridden.txt vendored Normal file
View File

@@ -0,0 +1 @@
QUX='from_os'

1
testdata/env/overridden.txt vendored Normal file
View File

@@ -0,0 +1 @@
QUX='from_taskfile'

View File

@@ -0,0 +1,5 @@
GOOS='linux' GOARCH='amd64' CGO_ENABLED='0'
FOO='foo' BAR='overridden' BAZ='baz'
QUX='from_os'
FOO='1' BAR='true' BAZ='1.1'
foo

View File

@@ -0,0 +1,5 @@
GOOS='linux' GOARCH='amd64' CGO_ENABLED='0'
FOO='foo' BAR='overridden' BAZ='baz'
QUX='from_taskfile'
FOO='1' BAR='true' BAZ='1.1'
foo