Remove unused internal functions#2907
Conversation
test.ps1 -CC traces the parent process, but the Output and InNewProcess tests run Pester in a child process through Invoke-InNewProcess and assert on its output. So the failure rendering, CI format output and discovery messages are covered by tests, the tracer just never sees them and reports them as missed, which makes the coverage number lie about what is actually tested. When -CC is on the parent now points the children at a drop folder and the same coverage target via PESTER_CC_CHILD_* env vars, which the child process inherits. Each child traces itself the same way the parent does, dumps the path + line:column it hit, and the parent merges those into the measure before the report. Parent and child trace the same files, so a child hit maps onto the same not yet hit point and we just flip it to Hit (the point is a struct, so copy, set, write back, same as the tracer does on a live hit). When -CC is off nothing changes, the child just runs . $ScriptBlock as before. Output.ps1 goes from 74% to 80%, overall from 85.7% to 86.4%. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
These internal functions have no callers left in src or tst (checked case insensitively, ignoring comments and their own definition), and none are exported. Grouped: - Old v4 assertion messages: the orphaned Should<Name>FailureMessage and NotShould<Name>FailureMessage pairs for BeGreaterThan, BeIn, BeLessThan, BeLike, BeLikeExactly, BeOfType, BeTrueOrFalse, Contain and HaveCount, plus Get-FailureMessage. The operators build the message inline now. Be, Match and FileContentMatch still call theirs so they stay, and Exist and Throw stay because Should.Tests.ps1 asserts their message functions exist. - Unfinished pretty printer in Format.ps1: Format-Object, Format-Hashtable, Format-Dictionary, Get-DisplayProperty. Format-Nicely returns the value as a string and the advanced path is commented out. - Orphaned helpers across Mock, RSpec, Runtime, Coverage, Debugging and Utility (Run-Test, Merge-CommandCoverage, Show-ParentList, Add-MockBehavior, FindMock, LastThat, Test-IsClosure, Reset-ConflictingParameters, New-BlockWithoutParameterAliases, New-OneTimeBlockSetup, Set-CurrentBlock, Reset-TestSuiteTimer, New-DiscoveredBlockContainerObject, Get-SessionStateHint, Assert-RunInProgress, and the Pester.Utility dictionary helpers). Full test.ps1 run passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
b5b92cd to
a5680b7
Compare
|
Quick reminder that we support
Both |
Count is not an approved verb and Scopes is plural, PSScriptAnalyzer flags it. Internal debug helper, only caller is Write-ScriptBlockInvocationHint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Yeah they're dead. The |
Co-authored-by: Jakub Jareš <me@jakubjares.com>
Draft, and stacked on #2906. It branches off that PR, so until #2906 merges the diff here shows both changes, review this one after that lands and it rebases clean.
While generating a full coverage report I noticed a chunk of the missed lines are not gaps, they are internal functions that nothing calls anymore. This removes 51 of them. Each one has no callers in
srcortst(checked case insensitively, ignoring comments and its own definition), and none are exported.By group:
Should<Name>FailureMessage/NotShould<Name>FailureMessagepairs for BeGreaterThan, BeIn, BeLessThan, BeLike, BeLikeExactly, BeOfType, BeTrueOrFalse, Contain and HaveCount, plusGet-FailureMessage. The operators build the message inline now. Be, Match and FileContentMatch still call theirs so they stay. Exist and Throw also stay, becauseShould.Tests.ps1asserts their message functions exist (it builds the names as strings, so a plain grep does not see that use).Format-Object,Format-Hashtable,Format-Dictionary,Get-DisplayProperty.Format-Nicelyreturns the value as a string and the advanced path is commented out.Run-Test,Merge-CommandCoverage,Show-ParentList,Add-MockBehavior,FindMock,LastThat,Test-IsClosure,Reset-ConflictingParameters,New-BlockWithoutParameterAliases,New-OneTimeBlockSetup,Set-CurrentBlock,Reset-TestSuiteTimer,New-DiscoveredBlockContainerObject,Get-SessionStateHint,Assert-RunInProgress, and thePester.Utilitydictionary helpers.Verification
Full
test.ps1run passes (P tests and Pester tests, 2606 passed, 0 failed). Every touched file parses.Notes for review
Sort-Propertyin Format.ps1 is now only reachable from the removedGet-DisplayProperty, so it is dead too, I left it in this pass, easy to drop as a follow up.PostProcess-RspecTestRunandRemove-RSpecNonPublicPropertiesare defined with lowercaseRspecbut called withRSpec/RSPec, they only work because PowerShell is case insensitive.ConvertTo-PesterResulthas no production caller, it is kept because a test uses it as the canary for "internals do not leak to the SUT".