Repository navigation
Conversation
A type whose own string form is short and on one line can say what the value is, which is what a test name wants: three cases over three versions used to come out as "supports [version]" three times, with nothing in the name to tell them apart. The type name is still the fallback, for a value that has no string form of its own, or one that is long or spans lines. Fix #3102 🤖
Length is what the file holds right now, so a test name built from a FileInfo changed whenever the file did, and a name that is not stable across runs cannot be matched to the same test's earlier results in the NUnit and JUnit reports. Name and FullName identify the file. 🤖
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #3102
A
<token>in a test name is rendered by the same formatter that writes assertion messages. When the value is an object the formatter does not know, it prints the object's type instead of walking its properties, which is what fixed the hang in #2865. The type name is the same string for every value of that type, so a data-driven test over three versions came out with one name three times:A type that has a short string form of its own can say what the value is, so the formatter now asks for that form first and keeps the type name as the fallback.
Every value from the issue, measured
Same file, same cases, each version in its own
pwshprocess on macOS:'hello'hellohellohello42424242[version]'1.2.3'1.2.3[version]1.2.3[uri]'https://example.com/a'https://example.com/a[uri]https://example.com/a[pscustomobject]@{A=1;B='two'}@{A=1; B=two}[PSObject]@{A=1; B=two}[ipaddress]'127.0.0.1'127.0.0.1[ipaddress]127.0.0.1@{ ver = [version]'1.0.0' }System.Collections.Hashtable@{ver=[version]}@{ver=1.0.0}Get-Item /etc/hosts/etc/hostsIO.FileInfo{FullName='/etc/hosts'; Length=213; Name='hosts'}IO.FileInfo{FullName='/etc/hosts'; Name='hosts'}Get-Command Get-ItemGet-ItemManagement.Automation.CmdletInfo{Name='Get-Item'}Get-Process -Id $pidSystem.Diagnostics.Process (pwsh)Diagnostics.Process{Id=3713; Name='pwsh'}@{A=1}System.Collections.Hashtable@{A=1}@(1,2,3)1 2 3@(1, 2, 3){ 1 + 1 }1 + 1{ 1 + 1 }[guid]'...0001',[timespan],[datetime],[DayOfWeek]The last rows are the point of what does not change: every case where Pester 6 already reads better than Pester 5, the hashtable, the array and the script block, is untouched, because the new text is only used where the output would otherwise be the bare type name.
The nested row is worth one note.
@{ ver = [version]'1.0.0' }was a name collision in 5.9.1 too, it just collided onSystem.Collections.Hashtableinstead.Why the names matter beyond reading them
Test names are the key in the NUnit and JUnit result files, so they are how Azure DevOps, GitHub and any home-grown comparison match a test to its history. Three cases that share one name cannot be told apart in a report, and a name that changes between runs cannot be matched to the same test's earlier results. That is also why
Lengthis out of theFileInfosummary now, in its own commit: it is what the file holds right now, so the test name changed whenever the file did.What this does not bring back
The hang in pester/Pester#2865 — Name expansion hangs on complex objects like CommandInfo. The property walk is still skipped at a shallow budget, and
CommandInfois still in the registry of types that are summarised by one property, so a wholeCommandInfoin a template still renders from itsNameand returns promptly. The new text comes from the value's own string form, which PowerShell builds one level deep and which does not walk the property graph.Values whose string form would be unreadable fall back to the type, so an object with no string form of its own, one longer than 100 characters, or one that spans lines keeps the old output:
Full assertion messages are unaffected. They start with the full recursion budget, so a value there never reaches the point where it would collapse to a type name in the first place:
Format-Nicely2on aPSCustomObjectstill printsPSObject{Age=28; Name='Jakub'}as before.🤖