mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Add tests for native command arguments
This commit is contained in:
1 parent
77a4e96795
commit
7816516c24
3 files changed
+87
No files matched your search
@@ -0,0 +1,31 @@
|
||||
Describe "Native Command Arguments" -tags "CI" {
|
||||
$testPath = 'TestDrive:\test.txt'
|
||||
$powershellTestDir = $PSScriptRoot
|
||||
while ($powershellTestDir -notmatch 'test[\\/]powershell$') {
|
||||
$powershellTestDir = Split-Path $powershellTestDir
|
||||
}
|
||||
$echoArgsDir = Join-Path (Split-Path $powershellTestDir) EchoArgs
|
||||
|
||||
function Start-EchoArgs {
|
||||
Push-Location $echoArgsDir
|
||||
try {
|
||||
dotnet run $args
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
It "Should handle quoted spaces correctly" {
|
||||
$a = 'a"b c"d'
|
||||
Start-EchoArgs $a 'a"b c"d' a"b c"d >$testPath
|
||||
$testPath | Should Contain 'Arg 0 is <ab cd>'
|
||||
$testPath | Should Contain 'Arg 1 is <ab cd>'
|
||||
$testPath | Should Contain 'Arg 2 is <ab cd>'
|
||||
}
|
||||
|
||||
It "Should handle spaces between escaped quotes" {
|
||||
Start-EchoArgs 'a\"b c\"d' "a\`"b c\`"d" >$testPath
|
||||
$testPath | Should Contain 'Arg 0 is <a"b c"d>'
|
||||
$testPath | Should Contain 'Arg 1 is <a"b c"d>'
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user