Test Changes to work with new Argument Escaping and Command Infra

This commit is contained in:
Bryan 2016-01-22 14:05:02 -08:00 committed by Bryan Thornbury
parent 8d0fada156
commit 37445f053d
18 changed files with 93 additions and 45 deletions

View file

@ -2,7 +2,7 @@
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<clear />
<add key="dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="nugetbuild" value="https://www.myget.org/F/nugetbuild/api/v3/index.json" />
<add key="AspNetCIDev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />

View file

@ -7,7 +7,7 @@
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>65741cb1-8aee-4c66-8198-10a7ea0e4258</ProjectGuid>
<RootNamespace>E2E</RootNamespace>
<RootNamespace>Microsoft.DotNet.Tests.EndToEnd</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>

View file

@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
{
private static readonly string s_expectedOutput = "Hello World!" + Environment.NewLine;
private static readonly string s_testdirName = "e2etestroot";
private static readonly string s_outputdirName = "testbin";
private static readonly string s_outputdirName = "test space/bin";
private string Rid { get; set; }
private string TestDirectory { get; set; }
@ -51,8 +51,6 @@ namespace Microsoft.DotNet.Tests.EndToEnd
[Fact]
public void TestDotnetIncrementalBuild()
{
TestSetup();
// first build
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory);
buildCommand.Execute().Should().Pass();

View file

@ -5,19 +5,21 @@
},
"dependencies": {
"NETStandard.Library" : "1.0.0-rc2-23704",
"NETStandard.Library" : "1.0.0-rc2-23706",
"xunit": "2.1.0",
"xunit.console.netcore": "1.0.2-prerelease-00101",
"xunit.netcore.extensions": "1.0.0-prerelease-*",
"xunit.runner.utility": "2.1.0",
"dotnet-test-xunit": "1.0.0-dev-*",
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
"Microsoft.DotNet.Tools.Tests.Utilities": "1.0.0-*"
"Microsoft.DotNet.ProjectModel": {"target":"project"},
"Microsoft.DotNet.Cli.Utils": {"target":"project"},
"Microsoft.DotNet.Tools.Tests.Utilities": {"target":"project"}
},
"frameworks": {
"dnxcore50": { }
}
},
"testRunner":"xunit"
}

View file

@ -15,7 +15,7 @@
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16530",
"Microsoft.DotNet.ProjectModel.Loader": "1.0.0-*"
"Microsoft.DotNet.ProjectModel.Loader": {"target":"project"}
},
"frameworks": {

View file

@ -1,6 +1,6 @@
{
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23704",
"Microsoft.NETCore.Platforms": "1.0.1-rc2-23706",
"Microsoft.DotNet.ProjectModel": {"target":"project"},
"Microsoft.DotNet.ProjectModel.Server": {"target":"project"},
"Newtonsoft.Json": "7.0.1",

View file

@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
new object[] { "", PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier(), "", "" },
new object[] { "", "", "Release", "" },
new object[] { "", "", "", "some/dir"},
//new object[] { "", "", "", "\"some/dir/with spaces\"" }, // issue - https://github.com/dotnet/cli/issues/525
new object[] { "", "", "", "some/dir/with spaces" },
new object[] { "dnxcore50", PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" },
};
}

View file

@ -2,9 +2,9 @@
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23704",
"Microsoft.NETCore.TestHost": "1.0.0-rc2-*",
"System.Text.RegularExpressions": "4.0.11-*",
"NETStandard.Library": "1.0.0-rc2-23706",
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23706",
"System.Text.RegularExpressions": "4.0.11-rc2-23706",
"xunit": "2.1.0",
"xunit.console.netcore": "1.0.2-prerelease-00101",

View file

@ -32,7 +32,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
{
return _outputDirectory == string.Empty ?
"" :
$"-o {_outputDirectory}";
$"-o \"{_outputDirectory}\"";
}
}
@ -214,7 +214,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
private string BuildArgs()
{
return $"{BuildProfile} {ForceIncrementalUnsafe} {_projectPath} {OutputOption} {TempOutputOption} {ConfigurationOption} {NoHostOption} {NativeOption} {ArchitectureOption} {IlcArgsOption} {IlcPathOption} {AppDepSDKPathOption} {NativeCppModeOption} {CppCompilerFlagsOption}";
return $"{BuildProfile} {ForceIncrementalUnsafe} \"{_projectPath}\" {OutputOption} {TempOutputOption} {ConfigurationOption} {NoHostOption} {NativeOption} {ArchitectureOption} {IlcArgsOption} {IlcPathOption} {AppDepSDKPathOption} {NativeCppModeOption} {CppCompilerFlagsOption}";
}
}
}

View file

@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
{
return _outputDirectory == string.Empty ?
"" :
$"-o {_outputDirectory}";
$"-o \"{_outputDirectory}\"";
}
}

View file

@ -102,7 +102,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
private string GetOutputOption()
{
return string.IsNullOrEmpty(_output) ? "" : $"-o {_output}";
return string.IsNullOrEmpty(_output) ? "" : $"-o \"{_output}\"";
}
private string GetConfigOption()

View file

@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
{
return _projectPath == string.Empty ?
"" :
$"-p {_projectPath}";
$"-p \"{_projectPath}\"";
}
}
@ -48,7 +48,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
get
{
return _preserveTemporary ?
$"-t {_projectPath}" :
$"-t \"{_projectPath}\"" :
"";
}
}

View file

@ -3,6 +3,7 @@
using Microsoft.DotNet.Cli.Utils;
using System;
using System.Diagnostics;
namespace Microsoft.DotNet.Tools.Test.Utilities
@ -19,23 +20,69 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
public virtual CommandResult Execute(string args = "")
{
Console.WriteLine($"Executing - {_command} {args}");
var commandResult = Command.Create(_command, args)
.ForwardStdErr()
.ForwardStdOut()
.Execute();
return commandResult;
var commandPath = Env.GetCommandPath(_command) ??
Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, _command);
var stdOut = new StreamForwarder();
var stdErr = new StreamForwarder();
stdOut.ForwardTo(write: Reporter.Output.Write, writeLine: Reporter.Output.WriteLine);
stdErr.ForwardTo(write: Reporter.Error.Write, writeLine: Reporter.Output.WriteLine);
return RunProcess(commandPath, args, stdOut, stdErr);
}
public virtual CommandResult ExecuteWithCapturedOutput(string args = "")
{
Console.WriteLine($"Executing (Captured Output) - {_command} {args}");
var commandResult = Command.Create(_command, args)
.CaptureStdErr()
.CaptureStdOut()
.Execute();
return commandResult;
var commandPath = Env.GetCommandPath(_command, ".exe", ".cmd", "") ??
Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, _command, ".exe", ".cmd", "");
Console.Write("command");
Console.WriteLine(commandPath);
var stdOut = new StreamForwarder();
var stdErr = new StreamForwarder();
stdOut.Capture();
stdErr.Capture();
return RunProcess(commandPath, args, stdOut, stdErr);
}
private CommandResult RunProcess(string executable, string args, StreamForwarder stdOut, StreamForwarder stdErr)
{
var psi = new ProcessStartInfo
{
FileName = executable,
Arguments = args,
RedirectStandardError = true,
RedirectStandardOutput = true
};
var process = new Process
{
StartInfo = psi
};
process.EnableRaisingEvents = true;
process.Start();
var threadOut = stdOut.BeginRead(process.StandardOutput);
var threadErr = stdErr.BeginRead(process.StandardError);
process.WaitForExit();
threadOut.Join();
threadErr.Join();
var result = new CommandResult(
process.ExitCode,
stdOut.GetCapturedOutput(),
stdErr.GetCapturedOutput());
return result;
}
}
}

View file

@ -3,18 +3,18 @@
"description": "Microsoft.DotNet.Tools.Tests.Utilities Class Library",
"dependencies": {
"System.Collections": "4.0.11-*",
"System.Collections.Immutable": "1.1.38-*",
"System.Linq": "4.0.1-*",
"System.Threading": "4.0.11-*",
"System.IO.FileSystem": "4.0.1-*",
"System.IO": "4.0.11-*",
"System.Runtime.InteropServices": "4.0.21-*",
"System.Text.RegularExpressions": "4.0.11-*",
"System.Collections": "4.0.11-rc2-*",
"System.Collections.Immutable": "1.1.38-rc2-*",
"System.Linq": "4.0.1-rc2-*",
"System.Threading": "4.0.11-rc2-*",
"System.IO.FileSystem": "4.0.1-rc2-*",
"System.IO": "4.0.11-rc2-*",
"System.Runtime.InteropServices": "4.0.21-rc2-*",
"System.Text.RegularExpressions": "4.0.11-rc2-*",
"FluentAssertions": "4.0.0",
"xunit": "2.1.0",
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
"Microsoft.DotNet.Cli.Utils": {"target":"project"},
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-16530"
},
@ -23,3 +23,4 @@
"dnxcore50": { }
}
}

View file

@ -5,7 +5,7 @@
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"NETStandard.Library": "1.0.0-rc2-23714",
"dotnet-hello": { "version": "1.0.0", "target": "package" }
},

View file

@ -7,7 +7,7 @@
"testRunner": "must-be-specified-to-generate-deps",
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"NETStandard.Library": "1.0.0-rc2-23714",
"dotnet-hello": {"version": "1.0.0", "target": "package"}
},

View file

@ -5,7 +5,7 @@
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616"
"NETStandard.Library": "1.0.0-rc2-23714"
},
"frameworks": {

View file

@ -5,7 +5,7 @@
},
"dependencies": {
"NETStandard.Library" : "1.0.0-rc2-23704",
"NETStandard.Library" : "1.0.0-rc2-23706",
"xunit": "2.1.0",
"xunit.console.netcore": "1.0.2-prerelease-00101",