File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ function Get-ExecutableCommandExtensions {
6868 [Parameter (Mandatory )]
6969 [string ]$Name ,
7070 [Parameter (Mandatory )]
71+ [AllowEmptyString ()]
7172 [string ]$PathExtValue
7273 )
7374
@@ -107,6 +108,7 @@ function Get-ExecutableCommandSearchPaths {
107108 [CmdletBinding ()]
108109 param (
109110 [Parameter (Mandatory )]
111+ [AllowEmptyString ()]
110112 [string ]$PathValue
111113 )
112114
@@ -197,6 +199,7 @@ function Resolve-ExecutableCommand {
197199 [Parameter (Mandatory )]
198200 [string []]$SearchPaths ,
199201 [Parameter (Mandatory )]
202+ [AllowEmptyString ()]
200203 [string ]$PathExtValue ,
201204 [switch ]$AllMatches
202205 )
@@ -257,6 +260,7 @@ function Resolve-ExecutableCommandsBatch {
257260 [Parameter (Mandatory )]
258261 [string []]$SearchPaths ,
259262 [Parameter (Mandatory )]
263+ [AllowEmptyString ()]
260264 [string ]$PathExtValue ,
261265 [switch ]$AllMatches
262266 )
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ BeforeAll {
22 Import-Module " $PSScriptRoot \..\modules\commandDiscovery.psm1" - Force
33 $script :OriginalPath = [Environment ]::GetEnvironmentVariable(' PATH' , ' Process' )
44 $script :OriginalPathExt = [Environment ]::GetEnvironmentVariable(' PATHEXT' , ' Process' )
5+ # 测试会临时覆写 PATH,因此在进入各个用例前先解析 chmod 的绝对路径,避免 Unix 下创建测试命令失败。
6+ $script :ChmodPath = if ($IsWindows ) { $null } else { (Get-Command chmod - ErrorAction Stop).Source }
57}
68
79AfterAll {
@@ -26,7 +28,7 @@ function global:New-TestExecutableCommand {
2628
2729 $commandPath = Join-Path $Directory $Name
2830 Set-Content - Path $commandPath - Value " #!/usr/bin/env sh`n echo ok" - Encoding ascii
29- & chmod + x $commandPath
31+ & $ script :ChmodPath + x $commandPath
3032 return $commandPath
3133}
3234
You can’t perform that action at this time.
0 commit comments