diff --git a/src/Format2.ps1 b/src/Format2.ps1 index 38348fb0d..af9690c72 100644 --- a/src/Format2.ps1 +++ b/src/Format2.ps1 @@ -157,7 +157,10 @@ function Get-DisplayProperty2 ([Type]$Type) { # and for types that do not exist $propertyMap = @{ - 'System.Diagnostics.Process' = 'Id', 'Name' + 'System.Diagnostics.Process' = 'Id', 'Name' + # DirectoryInfo and FileInfo have circular references (Root, Directory) that cause infinite recursion + 'System.IO.DirectoryInfo' = 'Name', 'FullName' + 'System.IO.FileInfo' = 'Name', 'FullName', 'Length' } $propertyMap[$Type.FullName] diff --git a/src/functions/assertions/Exist.ps1 b/src/functions/assertions/Exist.ps1 index e6b0f58c8..f5bb74e04 100644 --- a/src/functions/assertions/Exist.ps1 +++ b/src/functions/assertions/Exist.ps1 @@ -12,7 +12,7 @@ `Should -Exist` calls Test-Path. Test-Path expects a file, returns $false because the file was removed, and fails the test. #> - [bool] $succeeded = & $SafeCommands['Test-Path'] $ActualValue + [bool] $succeeded = & $SafeCommands['Test-Path'] -LiteralPath $ActualValue if ($Negate) { $succeeded = -not $succeeded diff --git a/tst/functions/assertions/Exist.Tests.ps1 b/tst/functions/assertions/Exist.Tests.ps1 index 25e57f637..cf6e10891 100644 --- a/tst/functions/assertions/Exist.Tests.ps1 +++ b/tst/functions/assertions/Exist.Tests.ps1 @@ -11,9 +11,9 @@ InPesterModuleScope { "TestDrive:\nonexistant" | Should -Not -Exist } - It 'works for path with escaped [ ] characters' { + It 'works for path with literal [ ] characters' { New-Item -Path "TestDrive:\[test].txt" -ItemType File | Out-Null - "TestDrive:\``[test``].txt" | Should -Exist + "TestDrive:\[test].txt" | Should -Exist } It 'returns correct result for function drive' {