From a9bf2c8020385b7fe90449a2c6147c1f4d2ab706 Mon Sep 17 00:00:00 2001 From: Valentin Maerten Date: Sat, 29 Aug 2026 11:05:08 +0200 Subject: [PATCH] refactor(completion): move the shell test harness out of completion/ Packaging globs completion/ into the release archives, so the harness added alongside the engine was about to ship run.sh and five wrapper scripts to every user. The previous commit worked around it by listing the packaged directories one by one, which quietly stops packaging any shell added later. Moving the harness to testdata/completion/ leaves completion/ holding only what we ship, so the glob can go back to completion/**/* and needs no maintenance when a shell is added. --- .goreleaser.yml | 7 +------ Taskfile.yml | 3 ++- {completion/tests => testdata/completion}/run.sh | 0 {completion/tests => testdata/completion}/wrapper.bash | 2 +- {completion/tests => testdata/completion}/wrapper.fish | 2 +- {completion/tests => testdata/completion}/wrapper.nu | 2 +- {completion/tests => testdata/completion}/wrapper.ps1 | 2 +- {completion/tests => testdata/completion}/wrapper.zsh | 2 +- 8 files changed, 8 insertions(+), 12 deletions(-) rename {completion/tests => testdata/completion}/run.sh (100%) rename {completion/tests => testdata/completion}/wrapper.bash (96%) rename {completion/tests => testdata/completion}/wrapper.fish (96%) rename {completion/tests => testdata/completion}/wrapper.nu (97%) rename {completion/tests => testdata/completion}/wrapper.ps1 (98%) rename {completion/tests => testdata/completion}/wrapper.zsh (98%) diff --git a/.goreleaser.yml b/.goreleaser.yml index cff7c73e..245ac343 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -43,12 +43,7 @@ archives: files: - README.md - LICENSE - - completion/bash/* - - completion/fish/* - - completion/nu/* - - completion/ps/* - - completion/zsh/* - - completion/legacy/**/* + - completion/**/* format_overrides: - goos: windows formats: [zip] diff --git a/Taskfile.yml b/Taskfile.yml index df62a0a4..32dd1512 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -164,8 +164,9 @@ tasks: - internal/complete/**/*.go - cmd/task/**/*.go - completion/**/* + - testdata/completion/* cmds: - - bash completion/tests/run.sh + - bash testdata/completion/run.sh goreleaser:test: desc: Tests release process without publishing diff --git a/completion/tests/run.sh b/testdata/completion/run.sh similarity index 100% rename from completion/tests/run.sh rename to testdata/completion/run.sh diff --git a/completion/tests/wrapper.bash b/testdata/completion/wrapper.bash similarity index 96% rename from completion/tests/wrapper.bash rename to testdata/completion/wrapper.bash index 8fc5c172..63cfcbd4 100755 --- a/completion/tests/wrapper.bash +++ b/testdata/completion/wrapper.bash @@ -22,7 +22,7 @@ _filedir() { CAP+="filedir:$* cur=$cur"$'\n'; } compopt() { CAP+="compopt:$*"$'\n'; } __ltrim_colon_completions() { :; } -source "$(dirname "${BASH_SOURCE[0]}")/../bash/task.bash" +source "$(dirname "${BASH_SOURCE[0]}")/../../completion/bash/task.bash" run() { CAP="" diff --git a/completion/tests/wrapper.fish b/testdata/completion/wrapper.fish similarity index 96% rename from completion/tests/wrapper.fish rename to testdata/completion/wrapper.fish index 51eb3173..aa583341 100755 --- a/completion/tests/wrapper.fish +++ b/testdata/completion/wrapper.fish @@ -3,7 +3,7 @@ # Set up by run.sh: TASK_FIXTURE, and `task` on PATH = the binary under test. cd $TASK_FIXTURE -source (dirname (status -f))/../fish/task.fish +source (dirname (status -f))/../../completion/fish/task.fish set -g fails 0 diff --git a/completion/tests/wrapper.nu b/testdata/completion/wrapper.nu similarity index 97% rename from completion/tests/wrapper.nu rename to testdata/completion/wrapper.nu index 019cfa56..e3339fa4 100644 --- a/completion/tests/wrapper.nu +++ b/testdata/completion/wrapper.nu @@ -4,7 +4,7 @@ # Set up by run.sh: $env.TASK_FIXTURE, and `task` on PATH = the binary under test. # `source` needs a parse-time constant path. -const TASK_NU = (path self "../nu/task-completions.nu") +const TASK_NU = (path self "../../completion/nu/task-completions.nu") # Installed before the wrapper is sourced, to assert the delegation path. $env.config.completions.external.completer = {|spans| [{ value: $"prev:($spans | first)" }] } diff --git a/completion/tests/wrapper.ps1 b/testdata/completion/wrapper.ps1 similarity index 98% rename from completion/tests/wrapper.ps1 rename to testdata/completion/wrapper.ps1 index 62429e1d..798b0423 100644 --- a/completion/tests/wrapper.ps1 +++ b/testdata/completion/wrapper.ps1 @@ -3,7 +3,7 @@ # the binary under test. Set-Location $env:TASK_FIXTURE -. "$PSScriptRoot/../ps/task.ps1" +. "$PSScriptRoot/../../completion/ps/task.ps1" $fails = 0 diff --git a/completion/tests/wrapper.zsh b/testdata/completion/wrapper.zsh similarity index 98% rename from completion/tests/wrapper.zsh rename to testdata/completion/wrapper.zsh index d52f1a36..c42f9ef2 100755 --- a/completion/tests/wrapper.zsh +++ b/testdata/completion/wrapper.zsh @@ -29,7 +29,7 @@ _files() { CAP+="files:$*"$'\n' } _path_files() { CAP+="path_files:$*"$'\n' } # Sourcing avoids the autoload first-call quirk; `compdef` is stubbed above. -source ${0:A:h}/../zsh/_task +source ${0:A:h}/../../completion/zsh/_task run() { CAP=""