Nothing tests the Build-PSBuildUpdatableHelp branch that deletes a consumer's output directory
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- powershell
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với Build-PSBuildUpdatableHelp và tests/Build-PSBuildHelp.tests.ps1, đặc biệt là thiết lập New-PSBuildDocsScenario hiện có và các lệnh gọi quanh các dòng 214, 271 và 330. Tạo sẵn UpdatableHelpPath cùng một tệp sentinel và một thư mục con, chạy hàm, rồi xác minh hành vi xóa dự kiến và cabinet mới được tạo; chạy tệp kiểm thử tập trung để xác nhận branch đã được bao phủ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Build-PSBuildUpdatableHelp contains the only code path in the module that deletes files a consumer may care about, and no test exercises it.
The branch
if (-not (Test-Path -LiteralPath $OutputPath)) {
New-Item @newItemSplat > $null
} else {
Write-Verbose ($LocalizedData.DirectoryAlreadyExists -f $OutputPath)
$removeItemSplat = @{
Recurse = $true
Force = $true
Verbose = ($VerbosePreference -eq 'Continue')
}
Get-ChildItem $OutputPath | Remove-Item @removeItemSplat
}
Get-ChildItem with no -Filter, then Remove-Item -Recurse -Force. Everything in OutputPath goes, whether PowerShellBuild wrote it or not.
Measured
Pointing the function at an OutputPath that already holds a previous build's output plus a directory PowerShellBuild never created:
BEFORE:
\PreviousBuild.cab
\Probe_HelpInfo.xml
\consumer-subfolder
\consumer-subfolder\notes.txt
AFTER:
(empty)
The deletion happens before any cabinet is written, so it also happens on a run that then fails — in the measurement above New-HelpCabinetFile errored afterwards, and the consumer was left with an empty directory and no new cabinet.
Nothing reaches it
Every call site in the suite supplies a fresh OutputPath that does not yet exist, so the New-Item branch is the only one taken:
tests/Build-PSBuildHelp.tests.ps1calls the function three times (lines 214, 271, 330), each with aUpdatableHelpPathfrom a distinctNew-PSBuildDocsScenario. That helper returns<scenario>/Output/UpdatableHelpfrom a freshly copied fixture, and the fixture (tests/fixtures/PSBuildTestFixture) contains noOutputdirectory. Nothing pre-creates the path, and no scenario is used twice.tests/build.tests.ps1runs theGenerateUpdatableHelptask once, in a job, and itsAfterAllremoves the output path afterwards.
There is no assertion anywhere that stale content is removed, and none that content outside PowerShellBuild's own output survives or does not.
Why it matters
$PSBPreference.Docs.UpdatableHelpOutDir is a consumer-set path. A consumer who points it at a directory that holds anything else — a checked-in HelpInfo.xml, a hand-maintained README, a sibling artifact directory, or in the worst case a path chosen carelessly — loses all of it on the next GenerateUpdatableHelp, silently, at Write-Verbose level.
The behaviour itself is defensible: leaving a previous build's cabinets in place would produce an output directory holding cabinets for commands that no longer exist, and the function's own comments explain that half-produced output is what the surrounding guards exist to prevent. What is not defensible is that it is the module's only destructive operation and the one behaviour with no test at all. Every other file-touching path in Build-PSBuildUpdatableHelp — the manifest guard, the HelpInfoUri guard, the missing landing page, the missing locale directory — was covered in #149 and #124. This one was not.
It is also cheap to test. The scenario helper already produces the directory layout; the test is one New-Item on UpdatableHelpPath and one sentinel file before the call.
Options
- Test the branch as written. Pre-create
OutputPath, drop a sentinel file and a sentinel subdirectory in it, run the function, and assert both are gone and the new cabinet is present. Cheap, and it pins the current contract so a future refactor cannot quietly change it in either direction. - Test it and narrow what is deleted. Remove only what this function produces —
*.cab,*.zip,*HelpInfo.xml— rather than the whole directory. Safer for a consumer who shares the directory, and it still solves the stale-cabinet problem the wholesale delete exists for. It does leave a cabinet behind if the locale ever changes, which the current behaviour handles. - Test it and require the directory to be PowerShellBuild's. Refuse, or warn, when
OutputPathalready contains files that do not match the produced set. Most protective, most surprising, and it would break a consumer whose directory legitimately holds something else. - Test it and document it. Keep the behaviour, and say in the README's settings table that
$PSBPreference.Docs.UpdatableHelpOutDiris cleared on every run. Whatever else is done, the table currently says nothing about it, and a consumer cannot learn this except by losing something.
(1) plus (4) is the minimum that makes the behaviour deliberate rather than incidental. (2) is worth weighing on its own merits, but the test should exist regardless of which behaviour is chosen — writing it first is what makes the choice visible.
Related: #149 (which added the rest of this function's coverage), #124 (the docs-tree locale handling immediately above this branch).
- Ngôn ngữ chính
- PowerShell
- Star
- 145
- Fork
- 27
- Merge trung bình
- 10 giờ 16 phút
- Pull request đã merge (30 ngày)
- 34
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của psake/PowerShellBuild
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
psake/PowerShellBuild#211 · 1 bình luận ·
-
CI: Install the built module from a local repository to verify install-time dependency behaviour Đang mởenhancement github_actions
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
psake/PowerShellBuild#229 ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
psake/PowerShellBuild#222 ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
psake/PowerShellBuild#221 ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
psake/PowerShellBuild#220 ·
Tất cả issue của psake/PowerShellBuild
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
copse-dev/agent-pane#2953 ·
-
bug ci-failure high priority
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
vllm-project/vllm-omni#7972 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
calcite-components needs triage refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Esri/calcite-design-system#15203 ·