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
This commit is contained in:
Douglas Thrift 2016-09-11 23:14:30 -07:00
parent 7816516c24
commit 7e8070276f
5 changed files with 20 additions and 16 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
bin/
obj/
run/
project.lock.json
*-tests.xml
/debug/

View File

@ -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 = ""

View File

@ -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 <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
& $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>'
}

View File

@ -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();
}
}
}