mirror of
https://github.com/go-task/task.git
synced 2026-09-01 19:50:16 +02:00
The engine shipped opt-in behind --new-completion, with the old scripts still on --completion. That split was never released, so flip it now rather than carry a third flag through a deprecation later. --completion serves the engine wrappers; the hand-written scripts move to completion/legacy/ and stay reachable via --legacy-completion for a release or two. .goreleaser.yml needed to follow: it packages the static files from completion/ into the deb/rpm/apk contents and the Homebrew cask, so leaving it untouched would have shipped the engine to anyone running `eval "$(task --completion zsh)"` and the old scripts to everyone installing from a package. The paths it references are unchanged and now resolve to the wrappers. Its archive glob is narrowed at the same time, so the test harness under completion/tests/ stops being shipped in the release archives.
68 lines
2.3 KiB
PowerShell
68 lines
2.3 KiB
PowerShell
# Smoke-tests how the PowerShell wrapper routes each directive, via the
|
|
# completion API. Set up by run.sh: $env:TASK_FIXTURE, and `task` on PATH =
|
|
# the binary under test.
|
|
|
|
Set-Location $env:TASK_FIXTURE
|
|
. "$PSScriptRoot/../ps/task.ps1"
|
|
|
|
$fails = 0
|
|
|
|
function Cands($line) {
|
|
([System.Management.Automation.CommandCompletion]::CompleteInput($line, $line.Length, $null)).CompletionMatches |
|
|
ForEach-Object { $_.CompletionText }
|
|
}
|
|
|
|
function Has($label, $line, $value) {
|
|
if ((Cands $line) -contains $value) {
|
|
Write-Output " ok $label"
|
|
} else {
|
|
Write-Output " FAIL $label — '$value' missing from: $((Cands $line) -join ' ')"
|
|
$script:fails++
|
|
}
|
|
}
|
|
|
|
function HasNot($label, $line, $value) {
|
|
if ((Cands $line) -contains $value) {
|
|
Write-Output " FAIL $label — '$value' should be absent"
|
|
$script:fails++
|
|
} else {
|
|
Write-Output " ok $label"
|
|
}
|
|
}
|
|
|
|
Write-Output "powershell: :4 (NoFileComp) forwards candidates, offers no files"
|
|
Has "candidate forwarded" 'task ' 'build'
|
|
HasNot "no file fallback" 'task ' 'notes.txt'
|
|
|
|
Write-Output "powershell: filters candidates by the current word"
|
|
Has "prefix keeps match" 'task b' 'build'
|
|
HasNot "prefix drops others" 'task b' 'deploy'
|
|
|
|
Write-Output "powershell: :16 (FilterDirs) offers directories only"
|
|
Has "dir offered" 'task --dir ' 'sub'
|
|
HasNot "no plain file" 'task --dir ' 'notes.txt'
|
|
|
|
Write-Output "powershell: :8 (FilterFileExt) filters by extension"
|
|
Has "matching file" 'task --taskfile ' 'Taskfile.yml'
|
|
HasNot "non-matching file" 'task --taskfile ' 'notes.txt'
|
|
|
|
Write-Output "powershell: nested path completion keeps the directory prefix"
|
|
Has "prefix kept" 'task --taskfile sub/' 'sub/nested.yml'
|
|
|
|
Write-Output "powershell: inline --flag=path keeps the --flag= prefix"
|
|
Has "inline nested" 'task --taskfile=sub/' '--taskfile=sub/nested.yml'
|
|
HasNot "inline non-matching" 'task --taskfile=' '--taskfile=notes.txt'
|
|
|
|
Write-Output "powershell: a quoted argument reaches the engine unquoted"
|
|
Has "single-quoted dir" "task --dir 'with space' " 'spaced'
|
|
Has "double-quoted dir" 'task --dir "with space" ' 'spaced'
|
|
|
|
Write-Output "powershell: a candidate holding a space is quoted for insertion"
|
|
Has "dir quoted" 'task --dir w' "'with space'"
|
|
|
|
if ($fails -ne 0) {
|
|
Write-Output "powershell: $fails failure(s)"
|
|
exit 1
|
|
}
|
|
Write-Output "powershell: all passed"
|