Skip to content

Commit 2b36f0c

Browse files
jawwad-aliclaude
andauthored
fix(powershell): stop Out-Null swallowing the AVAILABLE_DOCS status lines (#3891)
Test-FileExists / Test-DirHasFiles report their line with Write-Output and ALSO return $true/$false — both on the Success stream. The callers piped the whole call to `| Out-Null` to discard the boolean, which discarded the report line with it, so text mode printed the header and nothing under it: BEFORE (measured, powershell.exe -NoProfile -File ... -IncludeTasks): FEATURE_DIR:...\specs\001-f AVAILABLE_DOCS: (2 lines) AFTER: FEATURE_DIR:...\specs\001-f AVAILABLE_DOCS: [OK] research.md [FAIL] data-model.md [FAIL] contracts/ [FAIL] quickstart.md [FAIL] tasks.md (7 lines) The bash and Python twins both list every document under that header, so the PowerShell variant silently returned less information for the same inputs. Filter out only the boolean, keeping the report lines. Adds the first PowerShell text-mode test in this file (every existing PS test is -Json). File stays ASCII-only (verified 0 non-ASCII bytes). Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent c807e24 commit 2b36f0c

2 files changed

Lines changed: 46 additions & 6 deletions

File tree

‎scripts/powershell/check-prerequisites.ps1‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,18 @@ if ($Json) {
157157
Write-Output "FEATURE_DIR:$($paths.FEATURE_DIR)"
158158
Write-Output "AVAILABLE_DOCS:"
159159

160-
# Show status of each potential document
161-
Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Out-Null
162-
Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Out-Null
163-
Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Out-Null
164-
Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Out-Null
160+
# Show status of each potential document.
161+
# These helpers report their line with Write-Output and ALSO return a
162+
# bool, both on the Success stream, so 'Out-Null' discarded the report
163+
# line along with the return value and left AVAILABLE_DOCS empty. Drop
164+
# only the boolean so the per-document lines reach stdout like the
165+
# bash and Python twins.
166+
Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Where-Object { $_ -isnot [bool] }
167+
Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Where-Object { $_ -isnot [bool] }
168+
Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Where-Object { $_ -isnot [bool] }
169+
Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Where-Object { $_ -isnot [bool] }
165170

166171
if ($IncludeTasks) {
167-
Test-FileExists -Path $paths.TASKS -Description 'tasks.md' | Out-Null
172+
Test-FileExists -Path $paths.TASKS -Description 'tasks.md' | Where-Object { $_ -isnot [bool] }
168173
}
169174
}

‎tests/test_check_prerequisites_python_parity.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,38 @@ def test_hyphen_separator_is_still_honoured(self, tmp_path: Path):
564564
"integration_settings": {"droid": {"invoke_separator": "-"}},
565565
})
566566
assert common.get_invoke_separator(self._repo(tmp_path, body)) == "-"
567+
568+
569+
@pytest.mark.skipif(
570+
not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available"
571+
)
572+
def test_powershell_text_output_lists_available_docs(prereq_repo: Path) -> None:
573+
"""Text mode must print a status line per document, like the twins.
574+
575+
`Test-FileExists` / `Test-DirHasFiles` report their line with `Write-Output`
576+
and ALSO `return $true/$false`, both on the Success stream. The callers piped
577+
the whole call to `| Out-Null` to discard the boolean, which discarded the
578+
report line too — so `AVAILABLE_DOCS:` was emitted with nothing under it
579+
while the bash and Python twins list every document.
580+
"""
581+
feat = prereq_repo / "specs" / "001-my-feature"
582+
feat.mkdir(parents=True)
583+
(feat / "plan.md").write_text("# plan\n", encoding="utf-8")
584+
(feat / "research.md").write_text("# research\n", encoding="utf-8")
585+
_write_feature_json(prereq_repo)
586+
587+
ps = _run(_ps_cmd(prereq_repo, "-IncludeTasks"), prereq_repo)
588+
589+
assert ps.returncode == 0, ps.stderr
590+
assert "AVAILABLE_DOCS:" in ps.stdout
591+
for doc in (
592+
"research.md",
593+
"data-model.md",
594+
"contracts/",
595+
"quickstart.md",
596+
"tasks.md",
597+
):
598+
assert doc in ps.stdout, (doc, ps.stdout)
599+
# The existing file reports [OK], the missing ones [FAIL].
600+
assert "[OK] research.md" in _normalize_status_text(ps.stdout), ps.stdout
601+
assert "[FAIL] quickstart.md" in _normalize_status_text(ps.stdout), ps.stdout

0 commit comments

Comments
 (0)