From 7e8070276f30712ec39d1d69f7e4eb7ed80d6a9e Mon Sep 17 00:00:00 2001 From: Douglas Thrift Date: Sun, 11 Sep 2016 23:14:30 -0700 Subject: [PATCH] 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 --- .gitignore | 1 + build.psm1 | 16 ++++++++++++++++ .../NativeCommandArguments.Tests.ps1 | 15 +++------------ test/{ => tools}/EchoArgs/EchoArgs.cs | 4 ---- test/{ => tools}/EchoArgs/project.json | 0 5 files changed, 20 insertions(+), 16 deletions(-) rename test/{ => tools}/EchoArgs/EchoArgs.cs (82%) rename test/{ => tools}/EchoArgs/project.json (100%) diff --git a/.gitignore b/.gitignore index c34b18504..99763674d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ bin/ obj/ +run/ project.lock.json *-tests.xml /debug/ diff --git a/build.psm1 b/build.psm1 index ad3891a66..b668b3aec 100644 --- a/build.psm1 +++ b/build.psm1 @@ -547,6 +547,20 @@ function Get-PesterTag { $o } +function Publish-EchoArgs { + [CmdletBinding()] + param() + + Find-Dotnet + + Push-Location "$PSScriptRoot/test/tools/EchoArgs" + try { + dotnet publish --output run + } finally { + Pop-Location + } +} + function Start-PSPester { [CmdletBinding()] param( @@ -563,6 +577,8 @@ function Start-PSPester { ) Write-Verbose "Running pester tests at '$path' with tag '$($Tag -join ''', ''')' and ExcludeTag '$($ExcludeTag -join ''', ''')'" -Verbose + # Publish EchoArgs so it can be run by tests + Publish-EchoArgs # All concatenated commands/arguments are suffixed with the delimiter (space) $Command = "" diff --git a/test/powershell/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 b/test/powershell/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 index bf26060cd..6d2541ea4 100644 --- a/test/powershell/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 +++ b/test/powershell/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 @@ -4,27 +4,18 @@ Describe "Native Command Arguments" -tags "CI" { 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 - } - } + $echoArgs = Join-Path (Split-Path $powershellTestDir) tools/EchoArgs/run/echoargs It "Should handle quoted spaces correctly" { $a = 'a"b c"d' - Start-EchoArgs $a 'a"b c"d' a"b c"d >$testPath + & $echoArgs $a 'a"b c"d' a"b c"d >$testPath $testPath | Should Contain 'Arg 0 is ' $testPath | Should Contain 'Arg 1 is ' $testPath | Should Contain 'Arg 2 is ' } It "Should handle spaces between escaped quotes" { - Start-EchoArgs 'a\"b c\"d' "a\`"b c\`"d" >$testPath + & $echoArgs 'a\"b c\"d' "a\`"b c\`"d" >$testPath $testPath | Should Contain 'Arg 0 is ' $testPath | Should Contain 'Arg 1 is ' } diff --git a/test/EchoArgs/EchoArgs.cs b/test/tools/EchoArgs/EchoArgs.cs similarity index 82% rename from test/EchoArgs/EchoArgs.cs rename to test/tools/EchoArgs/EchoArgs.cs index 88d0f5e40..ca2958fdf 100644 --- a/test/EchoArgs/EchoArgs.cs +++ b/test/tools/EchoArgs/EchoArgs.cs @@ -19,10 +19,6 @@ namespace Pscx.Applications { Console.WriteLine("Arg {0} is <{1}>", i, args[i]); } - - /*Console.WriteLine("\nCommand line:"); - Console.WriteLine(Environment.CommandLine);*/ - Console.WriteLine(); } } } diff --git a/test/EchoArgs/project.json b/test/tools/EchoArgs/project.json similarity index 100% rename from test/EchoArgs/project.json rename to test/tools/EchoArgs/project.json