-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Steps to reproduce:
Set-Alias -Name v -Value 'vncviewer.exe'; 1 | Assert-Equivalent -Expected 2
Output:
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:598
Line |
598 | v "`$Expected has type $(Get-Type $Expected), `$Actual has type $ …
| ~
| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify
| that the path is correct and try again.
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:604
Line |
604 | v "`$Expected is a value (value type, string, single value ar …
| ~
| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify
| that the path is correct and try again.
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:207
Line |
207 | v "Equivalency comparator is used, values will be compared fo …
| ~
| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify
| that the path is correct and try again.
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:256
Line |
256 | v "Comparing values as $(Format-Nicely (Get-Type $Expected)) beca …
| ~
| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify
| that the path is correct and try again.
v: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:262
Line |
262 | v -Difference "`$Actual is not equivalent to $(Format-Nicely …
| ~
| The term 'vncviewer.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify
| that the path is correct and try again.
OperationStopped: C:\Program Files\WindowsPowerShell\Modules\Assert\0.9.7\src\Equivalence\Assert-Equivalent.ps1:676
Line |
676 | throw [Assertions.AssertionException]$message
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Expected and actual are not equivalent! Expected: 2 Actual: 1 Summary: Expected '2' to be equivalent to the actual value, but got '1'.
The issue is caused by the command resolution order in PowerShell that gives aliases higher precedence than functions.
Assert-Equivalent
defines v
function (line 519) that is overshadowed by the v
alias:
function v {
[CmdletBinding()]
param(
[String] $String,
[Switch] $Difference,
[Switch] $Equivalence,
[Switch] $Skip
)
# we are using implict variable $Path
# from the parent scope, this is ugly
# and bad practice, but saves us ton of
# coding and boilerplate code
$p = ""
$p += if ($null -ne $Path) {
"($Path)"
}
$p += if ($Difference) {
" DIFFERENCE"
}
$p += if ($Equivalence) {
" EQUIVALENCE"
}
$p += if ($Skip) {
" SKIP"
}
$p += if (""-ne $p) {
" - "
}
Write-Verbose ("$p$String".Trim() + " ")
}
@nohwnd: Since the assert functions have been moved to Pester v6
, would you accept PR to Assert
module fixing the issue? I have noticed that in Pester v6
the v
function has been renamed to Write-EquivalenceResult
. I could backport it to the Assert
module if you are still accepting the PRs.
For others, the workaround is not to use v
alias 🤷♂️
Edit:
I have done the PR anyways... could not help myself 😜
Metadata
Metadata
Assignees
Labels
No labels