mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
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
This commit is contained in:
1 parent
96a81c626c
commit
0f60b69af4
1 file changed
+7
-5
+7
-5
@@ -7,17 +7,19 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
|
|||||||
BeforeAll {
|
BeforeAll {
|
||||||
# Create temporary EXE command files
|
# Create temporary EXE command files
|
||||||
$file1 = Setup -f WildCardCommandA.exe -pass
|
$file1 = Setup -f WildCardCommandA.exe -pass
|
||||||
$file2 = Setup -f WildCard
|
$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 WildCardCommandA.exe) -ErrorAction Ignore
|
||||||
$null = New-Item -ItemType File -Path (Join-Path $TestDRive WildCardCommand[B].exe) -ErrorAction Ignore
|
#$null = New-Item -ItemType File -Path (Join-Path $TestDRive WildCardCommand[B].exe) -ErrorAction Ignore
|
||||||
if ( $IsLinux -or $IsOSX ) {
|
if ( $IsLinux -or $IsOSX ) {
|
||||||
/bin/chmod +x
|
/bin/chmod 777 "$file1"
|
||||||
|
/bin/chmod 777 "$file2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Test wildcard with drive relative directory path" {
|
It "Test wildcard with drive relative directory path" {
|
||||||
$pathName = Join-Path $TestDrive "WildCardCommandA*"
|
$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 = Get-Command -Name $pathName
|
||||||
$result | Should Not Be $null
|
$result | Should Not Be $null
|
||||||
$result.Name | Should Be WildCardCommandA.exe
|
$result.Name | Should Be WildCardCommandA.exe
|
||||||
|
|||||||
Reference in new issue
Block a user