💫 Toolkit to help you get started with SDD or any other process!
fix(powershell): stop Out-Null swallowing setup-tasks AVAILABLE_DOCS lines (#4188)
Noor ul ain6b7f4aa844e0
diff --git a/scripts/powershell/setup-tasks.ps1 b/scripts/powershell/setup-tasks.ps1index 828ff4a5b..4adbbc4b9 100644--- a/scripts/powershell/setup-tasks.ps1+++ b/scripts/powershell/setup-tasks.ps1@@ -81,8 +81,13 @@ if ($Json) {Write-Output "FEATURE_DIR: $($paths.FEATURE_DIR)"Write-Output "TASKS_TEMPLATE: $(if ($tasksTemplate) { $tasksTemplate } else { 'not found' })"Write-Output "AVAILABLE_DOCS:"- Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Out-Null- Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Out-Null- Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Out-Null- Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Out-Null+ # These helpers report their line with Write-Output and ALSO return a+ # bool, both on the Success stream, so 'Out-Null' discarded the report+ # line along with the return value and left AVAILABLE_DOCS empty. Drop+ # only the boolean so the per-document lines reach stdout like the+ # bash and Python twins.+ Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Where-Object { $_ -isnot [bool] }+ Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Where-Object { $_ -isnot [bool] }+ Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Where-Object { $_ -isnot [bool] }+ Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Where-Object { $_ -isnot [bool] }}diff --git a/tests/test_setup_tasks.py b/tests/test_setup_tasks.pyindex a3f02b63a..56a8eae85 100644--- a/tests/test_setup_tasks.py+++ b/tests/test_setup_tasks.py@@ -796,6 +796,39 @@ def test_setup_tasks_ps_missing_template_errors(tasks_repo: Path) -> None:assert "tasks-template" in result.stderr.lower() or "tasks-template" in result.stdout.lower()[email protected](not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")+def test_setup_tasks_ps_text_output_lists_available_docs(tasks_repo: Path) -> None:+ """Text mode must print a status line per document, like the bash/Python twins.++ `Test-FileExists` / `Test-DirHasFiles` report their line with `Write-Output`+ and ALSO `return $true/$false`, both on the Success stream. Piping the whole+ call to `| Out-Null` discarded the boolean AND the report line, so+ `AVAILABLE_DOCS:` was emitted with nothing under it.+ """+ feat = _minimal_feature(tasks_repo)+ (feat / "research.md").write_text("# research\n", encoding="utf-8")++ script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"+ exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL++ result = subprocess.run(+ [exe, "-NoProfile", "-File", str(script)],+ cwd=tasks_repo,+ capture_output=True,+ text=True,+ check=False,+ env=_clean_env(),+ )++ assert result.returncode == 0, result.stderr + result.stdout+ assert "AVAILABLE_DOCS:" in result.stdout+ for doc in ("research.md", "data-model.md", "contracts/", "quickstart.md"):+ assert doc in result.stdout, (doc, result.stdout)+ normalized = result.stdout.replace("\r\n", "\n")+ assert "[OK] research.md" in normalized, normalized+ assert "[FAIL] data-model.md" in normalized, normalized++@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")def test_powershell_command_hint_normalizes_mixed_separators(tasks_repo: Path,