Skip to content

Commit 7e80702

Browse files
committed
Move and "publish" EchoArgs for the tests
* Move EchoArgs from test/EchoArgs to test/tools/EchoArgs * Use "dotnet publish" for building EchoArgs in build.psm1 so the test can call it directly
1 parent 7816516 commit 7e80702

5 files changed

Lines changed: 20 additions & 16 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bin/
22
obj/
3+
run/
34
project.lock.json
45
*-tests.xml
56
/debug/

build.psm1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,20 @@ function Get-PesterTag {
547547
$o
548548
}
549549

550+
function Publish-EchoArgs {
551+
[CmdletBinding()]
552+
param()
553+
554+
Find-Dotnet
555+
556+
Push-Location "$PSScriptRoot/test/tools/EchoArgs"
557+
try {
558+
dotnet publish --output run
559+
} finally {
560+
Pop-Location
561+
}
562+
}
563+
550564
function Start-PSPester {
551565
[CmdletBinding()]
552566
param(
@@ -563,6 +577,8 @@ function Start-PSPester {
563577
)
564578

565579
Write-Verbose "Running pester tests at '$path' with tag '$($Tag -join ''', ''')' and ExcludeTag '$($ExcludeTag -join ''', ''')'" -Verbose
580+
# Publish EchoArgs so it can be run by tests
581+
Publish-EchoArgs
566582
# All concatenated commands/arguments are suffixed with the delimiter (space)
567583
$Command = ""
568584

test/powershell/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,18 @@ Describe "Native Command Arguments" -tags "CI" {
44
while ($powershellTestDir -notmatch 'test[\\/]powershell$') {
55
$powershellTestDir = Split-Path $powershellTestDir
66
}
7-
$echoArgsDir = Join-Path (Split-Path $powershellTestDir) EchoArgs
8-
9-
function Start-EchoArgs {
10-
Push-Location $echoArgsDir
11-
try {
12-
dotnet run $args
13-
} finally {
14-
Pop-Location
15-
}
16-
}
7+
$echoArgs = Join-Path (Split-Path $powershellTestDir) tools/EchoArgs/run/echoargs
178

189
It "Should handle quoted spaces correctly" {
1910
$a = 'a"b c"d'
20-
Start-EchoArgs $a 'a"b c"d' a"b c"d >$testPath
11+
& $echoArgs $a 'a"b c"d' a"b c"d >$testPath
2112
$testPath | Should Contain 'Arg 0 is <ab cd>'
2213
$testPath | Should Contain 'Arg 1 is <ab cd>'
2314
$testPath | Should Contain 'Arg 2 is <ab cd>'
2415
}
2516

2617
It "Should handle spaces between escaped quotes" {
27-
Start-EchoArgs 'a\"b c\"d' "a\`"b c\`"d" >$testPath
18+
& $echoArgs 'a\"b c\"d' "a\`"b c\`"d" >$testPath
2819
$testPath | Should Contain 'Arg 0 is <a"b c"d>'
2920
$testPath | Should Contain 'Arg 1 is <a"b c"d>'
3021
}
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ static void Main(string[] args)
1919
{
2020
Console.WriteLine("Arg {0} is <{1}>", i, args[i]);
2121
}
22-
23-
/*Console.WriteLine("\nCommand line:");
24-
Console.WriteLine(Environment.CommandLine);*/
25-
Console.WriteLine();
2622
}
2723
}
2824
}

0 commit comments

Comments
 (0)