Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ protected override void EndProcessing()
string.Format(
System.Globalization.CultureInfo.InvariantCulture,
CommandBaseStrings.NativeCommandNotFound,
command
WithCommand[0]
)
),
"CommandNotFound",
ErrorCategory.InvalidArgument,
WithCommand
WithCommand[0]
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Describe 'Switch-Process tests for Unix' -Tags 'CI' {
$out = pwsh -noprofile -outputformat text -command { exec /bin/echo 1 -w 2 }
$out | Should -BeExactly '1 -w 2'
}

It 'Error is returned if target command is not found' {
$invalidCommand = 'doesNotExist'
$e = { Switch-Process $invalidCommand } | Should -Throw -ErrorId 'CommandNotFound,Microsoft.PowerShell.Commands.SwitchProcessCommand' -PassThru
$e.Exception.Message | Should -BeLike "*'$invalidCommand'*"
$e.TargetObject | Should -BeExactly $invalidCommand
}
}

Describe 'Switch-Process for Windows' -Tag 'CI' {
Expand Down