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,28 @@
|
||||
//---------------------------------------------------------------------
|
||||
// Author: Keith Hill
|
||||
//
|
||||
// Description: Very simple little console class that you can use to see
|
||||
// how PowerShell is passing parameters to legacy console
|
||||
// apps.
|
||||
//
|
||||
// Creation Date: March 06, 2006
|
||||
//---------------------------------------------------------------------
|
||||
using System;
|
||||
|
||||
namespace Pscx.Applications
|
||||
{
|
||||
class EchoArgs
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
Console.WriteLine("Arg {0} is <{1}>", i, args[i]);
|
||||
}
|
||||
|
||||
/*Console.WriteLine("\nCommand line:");
|
||||
Console.WriteLine(Environment.CommandLine);*/
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "echoargs",
|
||||
"version": "1.0.0-*",
|
||||
"description": "Very simple little console class that you can use to see how PowerShell is passing parameters to legacy console apps.",
|
||||
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": "1.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"runtimes": {
|
||||
"ubuntu.16.04-x64": { },
|
||||
"ubuntu.14.04-x64": { },
|
||||
"debian.8-x64": { },
|
||||
"centos.7-x64": { },
|
||||
"win7-x64": { },
|
||||
"win81-x64": { },
|
||||
"win10-x64": { },
|
||||
"osx.10.11-x64": { }
|
||||
}
|
||||
}
|
||||
@@ -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