diff --git a/NuGet.Config b/NuGet.Config index 737fbbd0d..e8911ab53 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -2,7 +2,7 @@ - + diff --git a/test/E2E/E2E.xproj b/test/E2E/E2E.xproj index 381c6d548..9d4c3826b 100644 --- a/test/E2E/E2E.xproj +++ b/test/E2E/E2E.xproj @@ -7,7 +7,7 @@ 65741cb1-8aee-4c66-8198-10a7ea0e4258 - E2E + Microsoft.DotNet.Tests.EndToEnd ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ diff --git a/test/E2E/EndToEndTest.cs b/test/E2E/EndToEndTest.cs index 28d54dd7b..135b56f4e 100644 --- a/test/E2E/EndToEndTest.cs +++ b/test/E2E/EndToEndTest.cs @@ -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(); diff --git a/test/E2E/project.json b/test/E2E/project.json index a5f6eccd5..62fd11737 100644 --- a/test/E2E/project.json +++ b/test/E2E/project.json @@ -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" } diff --git a/test/LoadContextTest/project.json b/test/LoadContextTest/project.json index 835e44567..27b0cd143 100644 --- a/test/LoadContextTest/project.json +++ b/test/LoadContextTest/project.json @@ -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": { diff --git a/test/Microsoft.DotNet.ProjectModel.Server.Tests/project.json b/test/Microsoft.DotNet.ProjectModel.Server.Tests/project.json index c3240988e..ddc8834fb 100644 --- a/test/Microsoft.DotNet.ProjectModel.Server.Tests/project.json +++ b/test/Microsoft.DotNet.ProjectModel.Server.Tests/project.json @@ -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", diff --git a/test/Microsoft.DotNet.Tools.Publish.Tests/Microsoft.DotNet.Tools.Publish.Tests.cs b/test/Microsoft.DotNet.Tools.Publish.Tests/Microsoft.DotNet.Tools.Publish.Tests.cs index 57af9bd01..cfbe30b67 100644 --- a/test/Microsoft.DotNet.Tools.Publish.Tests/Microsoft.DotNet.Tools.Publish.Tests.cs +++ b/test/Microsoft.DotNet.Tools.Publish.Tests/Microsoft.DotNet.Tools.Publish.Tests.cs @@ -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" }, }; } diff --git a/test/Microsoft.DotNet.Tools.Publish.Tests/project.json b/test/Microsoft.DotNet.Tools.Publish.Tests/project.json index a6244788e..e28caa44e 100644 --- a/test/Microsoft.DotNet.Tools.Publish.Tests/project.json +++ b/test/Microsoft.DotNet.Tools.Publish.Tests/project.json @@ -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", diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs index 4173bf679..9f65c5e44 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/BuildCommand.cs @@ -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}"; } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs index 2bb9007b7..99abacc46 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PackCommand.cs @@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { return _outputDirectory == string.Empty ? "" : - $"-o {_outputDirectory}"; + $"-o \"{_outputDirectory}\""; } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs index a5af37c7c..5da0ea99d 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs @@ -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() diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/RunCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/RunCommand.cs index e67f30534..ea832f1da 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/RunCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/RunCommand.cs @@ -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}\"" : ""; } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs index 5ac357740..f44449cc6 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs @@ -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; } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json b/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json index 5f9ec376d..c6be5a6e9 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json @@ -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": { } } } + diff --git a/test/PackagedCommands/Consumers/AppWithDirectAndToolDependency/project.json.template b/test/PackagedCommands/Consumers/AppWithDirectAndToolDependency/project.json.template index df9dc83b5..548ea62e2 100644 --- a/test/PackagedCommands/Consumers/AppWithDirectAndToolDependency/project.json.template +++ b/test/PackagedCommands/Consumers/AppWithDirectAndToolDependency/project.json.template @@ -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" } }, diff --git a/test/PackagedCommands/Consumers/AppWithDirectDependency/project.json.template b/test/PackagedCommands/Consumers/AppWithDirectDependency/project.json.template index f2131a892..a17dc082c 100644 --- a/test/PackagedCommands/Consumers/AppWithDirectDependency/project.json.template +++ b/test/PackagedCommands/Consumers/AppWithDirectDependency/project.json.template @@ -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"} }, diff --git a/test/PackagedCommands/Consumers/AppWithToolDependency/project.json.template b/test/PackagedCommands/Consumers/AppWithToolDependency/project.json.template index 279122580..9419a649d 100644 --- a/test/PackagedCommands/Consumers/AppWithToolDependency/project.json.template +++ b/test/PackagedCommands/Consumers/AppWithToolDependency/project.json.template @@ -5,7 +5,7 @@ }, "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23616" + "NETStandard.Library": "1.0.0-rc2-23714" }, "frameworks": { diff --git a/test/StreamForwarderTests/project.json b/test/StreamForwarderTests/project.json index 2e21d6123..80cb9ffe1 100644 --- a/test/StreamForwarderTests/project.json +++ b/test/StreamForwarderTests/project.json @@ -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",