Skip to content

Commit d1c14ed

Browse files
fix(powershell): stop Out-Null swallowing setup-tasks AVAILABLE_DOCS lines
Test-FileExists / Test-DirHasFiles report their line with Write-Output and ALSO return $true/$false -- both on the Success stream. setup-tasks.ps1's text-mode branch piped each call to `| Out-Null` to discard the boolean, which discarded the report line with it, so AVAILABLE_DOCS: printed with nothing under it: BEFORE (measured, powershell.exe -NoProfile -File ...): FEATURE_DIR:...\specs\001-my-feature TASKS_TEMPLATE:...\tasks-template.md AVAILABLE_DOCS: (3 lines) AFTER: FEATURE_DIR:...\specs\001-my-feature TASKS_TEMPLATE:...\tasks-template.md AVAILABLE_DOCS: [OK] research.md [FAIL] data-model.md [FAIL] contracts/ [FAIL] quickstart.md (7 lines) The bash twin (scripts/bash/setup-tasks.sh) lists every document under that header, so the PowerShell variant silently returned less information for the same inputs. Same bug, same fix shape (filter out only the boolean with Where-Object) as the sibling that was just fixed in check-prerequisites.ps1 (upstream commit 2b36f0c, PR #3891) -- this is the unfixed twin call site sharing the same Test-FileExists/Test-DirHasFiles helpers in common.ps1. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 61be959 commit d1c14ed

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

‎scripts/powershell/setup-tasks.ps1‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,13 @@ if ($Json) {
8181
Write-Output "FEATURE_DIR: $($paths.FEATURE_DIR)"
8282
Write-Output "TASKS_TEMPLATE: $(if ($tasksTemplate) { $tasksTemplate } else { 'not found' })"
8383
Write-Output "AVAILABLE_DOCS:"
84-
Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Out-Null
85-
Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Out-Null
86-
Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Out-Null
87-
Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Out-Null
84+
# These helpers report their line with Write-Output and ALSO return a
85+
# bool, both on the Success stream, so 'Out-Null' discarded the report
86+
# line along with the return value and left AVAILABLE_DOCS empty. Drop
87+
# only the boolean so the per-document lines reach stdout like the
88+
# bash and Python twins.
89+
Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Where-Object { $_ -isnot [bool] }
90+
Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Where-Object { $_ -isnot [bool] }
91+
Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Where-Object { $_ -isnot [bool] }
92+
Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Where-Object { $_ -isnot [bool] }
8893
}

‎tests/test_setup_tasks.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,39 @@ def test_setup_tasks_ps_missing_template_errors(tasks_repo: Path) -> None:
796796
assert "tasks-template" in result.stderr.lower() or "tasks-template" in result.stdout.lower()
797797

798798

799+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
800+
def test_setup_tasks_ps_text_output_lists_available_docs(tasks_repo: Path) -> None:
801+
"""Text mode must print a status line per document, like the bash/Python twins.
802+
803+
`Test-FileExists` / `Test-DirHasFiles` report their line with `Write-Output`
804+
and ALSO `return $true/$false`, both on the Success stream. Piping the whole
805+
call to `| Out-Null` discarded the boolean AND the report line, so
806+
`AVAILABLE_DOCS:` was emitted with nothing under it.
807+
"""
808+
feat = _minimal_feature(tasks_repo)
809+
(feat / "research.md").write_text("# research\n", encoding="utf-8")
810+
811+
script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"
812+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
813+
814+
result = subprocess.run(
815+
[exe, "-NoProfile", "-File", str(script)],
816+
cwd=tasks_repo,
817+
capture_output=True,
818+
text=True,
819+
check=False,
820+
env=_clean_env(),
821+
)
822+
823+
assert result.returncode == 0, result.stderr + result.stdout
824+
assert "AVAILABLE_DOCS:" in result.stdout
825+
for doc in ("research.md", "data-model.md", "contracts/", "quickstart.md"):
826+
assert doc in result.stdout, (doc, result.stdout)
827+
normalized = result.stdout.replace("\r\n", "\n")
828+
assert "[OK] research.md" in normalized, normalized
829+
assert "[FAIL] data-model.md" in normalized, normalized
830+
831+
799832
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
800833
def test_powershell_command_hint_normalizes_mixed_separators(
801834
tasks_repo: Path,

0 commit comments

Comments
 (0)