From 0f60b69af4d31262110f0d96acd2d5c6efa14e3e Mon Sep 17 00:00:00 2001 From: James Truher Date: Thu, 21 Jul 2016 11:44:12 -0700 Subject: [PATCH] Fix Get-Command tests to better handle non-Windows platforms. set executable bit on Linux/MacOS as that's what determines whether something is executable. Also simplify partial path creation, only remove up to the first colon, so those filesystems which have a single root are treated properly --- .../Pester.Commands.Cmdlets.GetCommand.Tests.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 index 5fcf4ff0f..0c99c4270 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 @@ -7,17 +7,19 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" { BeforeAll { # Create temporary EXE command files $file1 = Setup -f WildCardCommandA.exe -pass - $file2 = Setup -f WildCard - $null = New-Item -ItemType File -Path (Join-Path $TestDrive WildCardCommandA.exe) -ErrorAction Ignore - $null = New-Item -ItemType File -Path (Join-Path $TestDRive WildCardCommand[B].exe) -ErrorAction Ignore + $file2 = Setup -f WildCardCommand[B].exe -pass + #$null = New-Item -ItemType File -Path (Join-Path $TestDrive WildCardCommandA.exe) -ErrorAction Ignore + #$null = New-Item -ItemType File -Path (Join-Path $TestDRive WildCardCommand[B].exe) -ErrorAction Ignore if ( $IsLinux -or $IsOSX ) { - /bin/chmod +x + /bin/chmod 777 "$file1" + /bin/chmod 777 "$file2" } } It "Test wildcard with drive relative directory path" { $pathName = Join-Path $TestDrive "WildCardCommandA*" - $pathName = $pathName.Substring(2, ($pathName.Length - 2)) + $driveOffset = $pathName.IndexOf(":") + $pathName = $pathName.Substring($driveOffset + 1) $result = Get-Command -Name $pathName $result | Should Not Be $null $result.Name | Should Be WildCardCommandA.exe