From eb725048a8ac29ae5fb75e638e8fe85d1c297ecd Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Thu, 30 May 2019 14:40:41 -0700 Subject: [PATCH 1/3] Delete dead code --- .../CommandExtensions.cs | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/Tests/Microsoft.NET.TestFramework/CommandExtensions.cs diff --git a/src/Tests/Microsoft.NET.TestFramework/CommandExtensions.cs b/src/Tests/Microsoft.NET.TestFramework/CommandExtensions.cs deleted file mode 100644 index 299136ba1af3..000000000000 --- a/src/Tests/Microsoft.NET.TestFramework/CommandExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using FluentAssertions; -using Microsoft.DotNet.Cli.Utils; -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; -using Microsoft.NET.TestFramework.Assertions; - -namespace Microsoft.NET.TestFramework -{ - public static class CommandExtensions - { - public static ICommand EnsureExecutable(this ICommand command) - { - // Workaround for https://github.com/NuGet/Home/issues/4424 - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Command.Create("chmod", new[] { "755", command.CommandName }) - .Execute() - .Should() - .Pass(); - } - return command; - } - } -} From 4475e46538e173624a0492514ca95327341db69c Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Thu, 30 May 2019 14:43:13 -0700 Subject: [PATCH 2/3] Rename ShimCommand to RunExeCommand --- .../Commands/{ShimCommand.cs => RunExeCommand.cs} | 4 ++-- .../GivenThatWeWantToPackAToolProjectWithPackagedShim.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/Tests/Microsoft.NET.TestFramework/Commands/{ShimCommand.cs => RunExeCommand.cs} (87%) diff --git a/src/Tests/Microsoft.NET.TestFramework/Commands/ShimCommand.cs b/src/Tests/Microsoft.NET.TestFramework/Commands/RunExeCommand.cs similarity index 87% rename from src/Tests/Microsoft.NET.TestFramework/Commands/ShimCommand.cs rename to src/Tests/Microsoft.NET.TestFramework/Commands/RunExeCommand.cs index 4c25f72eb9a0..8aeddc82b355 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Commands/ShimCommand.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Commands/RunExeCommand.cs @@ -8,11 +8,11 @@ namespace Microsoft.NET.TestFramework.Commands { - public class ShimCommand : TestCommand + public class RunExeCommand : TestCommand { private readonly string _commandPath; - public ShimCommand(ITestOutputHelper log, string commandPath, params string[] args) : base(log) + public RunExeCommand(ITestOutputHelper log, string commandPath, params string[] args) : base(log) { if (!File.Exists(commandPath)) { diff --git a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs index 2b5c3c55a1b6..71c9a9184ecc 100644 --- a/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs +++ b/src/Tests/Microsoft.NET.ToolPack.Tests/GivenThatWeWantToPackAToolProjectWithPackagedShim.cs @@ -419,7 +419,7 @@ private void AssertValidShim(string testRoot, string nugetPackage) shimPath, null); - var command = new ShimCommand(Log, shimPath) + var command = new RunExeCommand(Log, shimPath) { WorkingDirectory = simulateToolPathRoot }; From 81b60761cd86bc76e351c3b6739dd91b7eaa75c5 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Thu, 30 May 2019 14:50:10 -0700 Subject: [PATCH 3/3] Use TestCommands for running apps This will include both STDOUT and STDERR in the log, as well as launched process path and args --- .../Microsoft.NET.Build.Tests/AppHostTests.cs | 6 ++--- .../GivenThatWeWantAllResourcesInSatellite.cs | 7 +++-- .../GivenThatWeWantToBuildADesktopExe.cs | 6 ++--- .../GivenThatWeWantToBuildANetCoreApp.cs | 3 +-- ...GivenThatWeWantToBuildASelfContainedApp.cs | 6 ++--- ...atWeWantToBuildAnAppWithLibrariesAndRid.cs | 7 ++--- .../GivenThatWeWantToBuildAnAppWithLibrary.cs | 6 ++--- ...ntToBuildAnAppWithTransitiveProjectRefs.cs | 3 +-- ...oBuildAnAppWithoutTransitiveProjectRefs.cs | 6 ++--- ...nThatWeWantToBuildAppsWithFrameworkRefs.cs | 3 +-- .../GivenThatWeWantToReferenceAnAssembly.cs | 26 +++++++------------ .../GivenThatWeWantToTargetNet471.cs | 3 +-- ...DepsJsonShouldContainVersionInformation.cs | 5 +--- ...atWeWantToPublishAFrameworkDependentApp.cs | 6 ++--- ...enThatWeWantToPublishAHelloWorldProject.cs | 13 ++++------ ...WeWantToPublishAProjectWithDependencies.cs | 5 +--- .../GivenThatWeWantToPublishAWebApp.cs | 3 +-- ...WeWantToPublishAnAppWithLibrariesAndRid.cs | 6 ++--- .../RuntimeIdentifiersTests.cs | 6 ++--- 19 files changed, 43 insertions(+), 83 deletions(-) diff --git a/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs b/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs index 0bd860953319..4889f393b4bb 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/AppHostTests.cs @@ -52,11 +52,11 @@ public void It_builds_a_runnable_apphost_by_default(string targetFramework) "HelloWorld.runtimeconfig.json", }); - Command.Create(Path.Combine(outputDirectory.FullName, hostExecutable), new string[] { }) - .EnvironmentVariable( + + new RunExeCommand(Log, Path.Combine(outputDirectory.FullName, hostExecutable)) + .WithEnvironmentVariable( Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)", Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath)) - .CaptureStdOut() .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantAllResourcesInSatellite.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantAllResourcesInSatellite.cs index e3965476fbb2..65f432468107 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantAllResourcesInSatellite.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantAllResourcesInSatellite.cs @@ -75,12 +75,12 @@ internal static void TestSatelliteResources( "en/AllResourcesInSatellite.resources.dll" }; - Command command; + TestCommand command; if (targetFramework == "net46") { outputFiles.Add("AllResourcesInSatellite.exe"); outputFiles.Add("AllResourcesInSatellite.exe.config"); - command = Command.Create(Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.exe"), Array.Empty()); + command = new RunExeCommand(log, Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.exe")); } else { @@ -88,13 +88,12 @@ internal static void TestSatelliteResources( outputFiles.Add("AllResourcesInSatellite.deps.json"); outputFiles.Add("AllResourcesInSatellite.runtimeconfig.json"); outputFiles.Add("AllResourcesInSatellite.runtimeconfig.dev.json"); - command = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.dll") }); + command = new DotnetCommand(log, Path.Combine(outputDirectory.FullName, "AllResourcesInSatellite.dll")); } outputDirectory.Should().OnlyHaveFiles(outputFiles); command - .CaptureStdOut() .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs index d98ace24ac02..077e281d9551 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopExe.cs @@ -108,9 +108,8 @@ public void It_handles_native_dependencies_and_platform_target( .Pass(); var exe = Path.Combine(buildCommand.GetOutputDirectory("net46").FullName, "DesktopMinusRid.exe"); - var runCommand = Command.Create(exe, Array.Empty()); + var runCommand = new RunExeCommand(Log, exe); runCommand - .CaptureStdOut() .Execute() .Should() .Pass() @@ -189,9 +188,8 @@ public void It_appends_rid_to_outdir_correctly(string identifier, string rid, bo { var exe = Path.Combine(directory.FullName, "DesktopMinusRid.exe"); - var runCommand = Command.Create(exe, Array.Empty()); + var runCommand = new RunExeCommand(Log, exe); runCommand - .CaptureStdOut() .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs index 0c4d324a75d0..3f13c9f1e1f1 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildANetCoreApp.cs @@ -366,8 +366,7 @@ public static void Main() string outputFolder = buildCommand.GetOutputDirectory(project.TargetFrameworks, runtimeIdentifier: runtimeIdentifier ?? "").FullName; - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputFolder, project.Name + ".dll") }) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(outputFolder, project.Name + ".dll")) .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs index 4f827644685a..f636b1db1fbb 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs @@ -81,8 +81,7 @@ public void It_builds_a_runnable_output(string targetFramework, bool dependencie $"apphost{Constants.ExeSuffix}", }); - Command.Create(selfContainedExecutableFullPath, new string[] { }) - .CaptureStdOut() + new RunExeCommand(Log, selfContainedExecutableFullPath) .Execute() .Should() .Pass() @@ -149,8 +148,7 @@ public void It_succeeds_when_RuntimeIdentifier_and_PlatformTarget_mismatch_but_P string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable); - Command.Create(selfContainedExecutableFullPath, new string[] { }) - .CaptureStdOut() + new RunExeCommand(Log, selfContainedExecutableFullPath) .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrariesAndRid.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrariesAndRid.cs index c68598d22920..65bc93e2c0c3 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrariesAndRid.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrariesAndRid.cs @@ -55,9 +55,7 @@ public void It_builds_a_RID_specific_runnable_output() string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable); - Command.Create(selfContainedExecutableFullPath, new string[] { }) - .CaptureStdOut() - .CaptureStdErr() + new RunExeCommand(Log, selfContainedExecutableFullPath) .Execute() .Should() .Pass() @@ -118,8 +116,7 @@ public void It_builds_a_framework_dependent_RID_specific_runnable_output() "LibraryWithRids.pdb", }); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "App.dll") }) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "App.dll")) .Execute() .Should().Pass() .And.HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' 3.13.0 '{runtimeIdentifier}' Hello World"); diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrary.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrary.cs index eed277df8871..64cef47068df 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrary.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrary.cs @@ -76,8 +76,7 @@ void VerifyAppBuilds(TestAsset testAsset) "TestLibrary.pdb", }); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "TestApp.dll") }) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "TestApp.dll")) .Execute() .Should() .Pass() @@ -121,8 +120,7 @@ public void It_generates_satellite_assemblies() var outputDir = buildCommand.GetOutputDirectory("netcoreapp2.0"); - var commandResult = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDir.FullName, "TestApp.dll") }) - .CaptureStdOut() + var commandResult = new DotnetCommand(Log, Path.Combine(outputDir.FullName, "TestApp.dll")) .Execute(); commandResult.Should().Pass(); diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs index 83a7585e0e0a..40d21d0f52d9 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs @@ -66,8 +66,7 @@ void VerifyAppBuilds(TestAsset testAsset) "AuxLibrary.pdb", }); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(outputDirectory.FullName, "TestApp.dll") }) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "TestApp.dll")) .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs index 6ad53578feca..baf007f12910 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs @@ -47,8 +47,7 @@ public void It_builds_the_project_successfully_when_RAR_finds_all_references() "5.pdb", }); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] {Path.Combine(outputDirectory.FullName, "1.dll")}) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "1.dll")) .Execute() .Should() .Pass() @@ -91,8 +90,7 @@ public void It_builds_the_project_successfully_when_RAR_does_not_find_all_refere "2.pdb", }); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] {Path.Combine(outputDirectory.FullName, "1.dll")}) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "1.dll")) .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAppsWithFrameworkRefs.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAppsWithFrameworkRefs.cs index 6cf61ce7c867..3b5da601f908 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAppsWithFrameworkRefs.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAppsWithFrameworkRefs.cs @@ -63,8 +63,7 @@ void VerifyProjectsBuild(TestAsset testAsset, params string[] buildArgs) var buildCommand = new BuildCommand(Log, appProjectDirectory); var outputDirectory = buildCommand.GetOutputDirectory("net451", runtimeIdentifier: "win7-x86"); - Command.Create(Path.Combine(outputDirectory.FullName, "EntityFrameworkApp.exe"), Enumerable.Empty()) - .CaptureStdOut() + new RunExeCommand(Log, Path.Combine(outputDirectory.FullName, "EntityFrameworkApp.exe")) .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs index 7aa2d550744f..070a93adfc7e 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToReferenceAnAssembly.cs @@ -86,8 +86,7 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() + new DotnetCommand(Log, applicationPath) .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello from a direct reference."); @@ -210,8 +209,7 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() + new DotnetCommand(Log, applicationPath) .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello World from en satellite assembly for a direct reference."); @@ -299,8 +297,7 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() + new DotnetCommand(Log, applicationPath) .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello from a reference of an indirect reference."); @@ -441,8 +438,7 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() + new DotnetCommand(Log, applicationPath) .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello World from en satellite assembly for a reference of an indirect reference."); @@ -531,8 +527,7 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() + new DotnetCommand(Log, applicationPath) .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello from an indirect reference."); @@ -674,8 +669,7 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() + new DotnetCommand(Log, applicationPath) .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello World from en satellite assembly for an indirect reference."); @@ -782,8 +776,7 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() + new DotnetCommand(Log, applicationPath) .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello from a reference of an indirect reference."); @@ -943,9 +936,8 @@ public static void Main() var referencerAsset = _testAssetsManager.CreateTestProject(referencerProject, identifier: identifier); string applicationPath = RestoreAndBuild(referencerAsset, referencerProject); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { applicationPath }) - .CaptureStdOut() - .Execute() + new DotnetCommand(Log, applicationPath) + .Execute() .Should().Pass() .And.HaveStdOutContaining("Hello World from en satellite assembly for a reference of an indirect reference."); } diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToTargetNet471.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToTargetNet471.cs index 41efe123120b..9ced105fec0f 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToTargetNet471.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToTargetNet471.cs @@ -454,8 +454,7 @@ public static Type [] GetTypes() var exePath = Path.Combine(buildCommand.GetOutputDirectory(testProject.TargetFrameworks).FullName, testProject.Name + ".exe"); - Command.Create(exePath, Array.Empty()) - .CaptureStdOut() + new RunExeCommand(Log, exePath) .Execute() .Should() .Pass(); diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs index 84f271d0fbb9..464a7832eb8f 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs @@ -229,12 +229,9 @@ public static void Main() // to force the .NET Core 2.0 app to run on that version string rollForwardVersion = GetRollForwardNetCoreAppVersion(); - var runAppCommand = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, - new string[] { "exec", "--fx-version", rollForwardVersion, exePath }); + var runAppCommand = new DotnetCommand(Log, "exec", "--fx-version", rollForwardVersion, exePath ); var runAppResult = runAppCommand - .CaptureStdOut() - .CaptureStdErr() .Execute(); runAppResult diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAFrameworkDependentApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAFrameworkDependentApp.cs index 0abd7b81b7d1..c52045c12a79 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAFrameworkDependentApp.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAFrameworkDependentApp.cs @@ -93,12 +93,10 @@ public void It_publishes_with_or_without_apphost(string useAppHost, string targe // Run the apphost if one was generated if (useAppHost != "false") { - Command.Create(Path.Combine(publishDirectory.FullName, appHostName), Enumerable.Empty()) - .EnvironmentVariable( + new RunExeCommand(Log, Path.Combine(publishDirectory.FullName, appHostName)) + .WithEnvironmentVariable( Environment.Is64BitProcess ? "DOTNET_ROOT" : "DOTNET_ROOT(x86)", Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath)) - .CaptureStdOut() - .CaptureStdErr() .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs index 1c690ac8a1a8..10cc68ff9b8e 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs @@ -54,8 +54,7 @@ public void It_publishes_portable_apps_to_the_publish_folder_and_the_app_should_ outputDirectory.Should().HaveFiles(filesPublished); publishDirectory.Should().HaveFiles(filesPublished); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(publishDirectory.FullName, "HelloWorld.dll") }) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(publishDirectory.FullName, "HelloWorld.dll")) .Execute() .Should() .Pass() @@ -117,8 +116,7 @@ public void It_publishes_self_contained_apps_to_the_publish_folder_and_the_app_s publishDirectory.Should().NotHaveFiles(filesNotPublished); string selfContainedExecutableFullPath = Path.Combine(publishDirectory.FullName, selfContainedExecutable); - Command.Create(selfContainedExecutableFullPath, new string[] { }) - .CaptureStdOut() + new RunExeCommand(Log, selfContainedExecutableFullPath) .Execute() .Should() .Pass() @@ -341,7 +339,7 @@ public static void Main() .And .OnlyHavePackagesWithPathProperties(); - ICommand runCommand; + TestCommand runCommand; if (selfContained) { @@ -372,7 +370,7 @@ public static void Main() .And .OnlyHaveNativeAssembliesWhichAreInFolder(rid, publishDirectory.FullName, testProject.Name); - runCommand = Command.Create(selfContainedExecutableFullPath, new string[] { }); + runCommand = new RunExeCommand(Log, selfContainedExecutableFullPath); } else { @@ -389,11 +387,10 @@ public static void Main() dependencyContext.Should() .OnlyHaveRuntimeAssemblies(rid ?? "", testProject.Name); - runCommand = Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(publishDirectory.FullName, $"{testProject.Name}.dll") }); + runCommand = new DotnetCommand(Log, Path.Combine(publishDirectory.FullName, $"{testProject.Name}.dll")); } runCommand - .CaptureStdOut() .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithDependencies.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithDependencies.cs index 8867982b70f7..d4aaabeda117 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithDependencies.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithDependencies.cs @@ -52,9 +52,7 @@ public void It_publishes_projects_with_simple_dependencies() string appPath = publishCommand.GetPublishedAppPath("SimpleDependencies"); - Command runAppCommand = Command.Create( - TestContext.Current.ToolsetUnderTest.DotNetHostPath, - new[] { appPath, "one", "two" }); + TestCommand runAppCommand = new DotnetCommand(Log, appPath, "one", "two" ); string expectedOutput = @"{ @@ -63,7 +61,6 @@ public void It_publishes_projects_with_simple_dependencies() }"; runAppCommand - .CaptureStdOut() .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs index a58ba437de53..079edce61f4f 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAWebApp.cs @@ -111,8 +111,7 @@ public void It_should_publish_self_contained_for_2x() $"apphost{Constants.ExeSuffix}", }); - Command.Create(Path.Combine(output.FullName, $"{testProject.Name}{Constants.ExeSuffix}"), new string[] {}) - .CaptureStdOut() + new RunExeCommand(Log, Path.Combine(output.FullName, $"{testProject.Name}{Constants.ExeSuffix}")) .Execute() .Should() .Pass() diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAppWithLibrariesAndRid.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAppWithLibrariesAndRid.cs index 2ef90c9c073e..099cc26fdb8e 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAppWithLibrariesAndRid.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAnAppWithLibrariesAndRid.cs @@ -53,8 +53,7 @@ public void It_publishes_a_self_contained_runnable_output() $"apphost{Constants.ExeSuffix}", }); - Command.Create(Path.Combine(publishDirectory.FullName, selfContainedExecutable), new string[] { }) - .CaptureStdOut() + new RunExeCommand(Log, Path.Combine(publishDirectory.FullName, selfContainedExecutable)) .Execute() .Should().Pass() .And.HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' 3.13.0 '{runtimeIdentifier}' Hello World"); @@ -83,8 +82,7 @@ public void It_publishes_a_framework_dependent_RID_specific_runnable_output() $"{FileConstants.DynamicLibPrefix}sqlite3{FileConstants.DynamicLibSuffix}", }); - Command.Create(TestContext.Current.ToolsetUnderTest.DotNetHostPath, new[] { Path.Combine(publishDirectory.FullName, "App.dll") }) - .CaptureStdOut() + new DotnetCommand(Log, Path.Combine(publishDirectory.FullName, "App.dll")) .Execute() .Should().Pass() .And.HaveStdOutContaining($"3.13.0 '{runtimeIdentifier}' 3.13.0 '{runtimeIdentifier}' Hello World"); diff --git a/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs index 63a1b2eccf84..a08c8d4b04aa 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs @@ -69,8 +69,7 @@ public void BuildWithRuntimeIdentifier() var selfContainedExecutable = $"{testProject.Name}{Constants.ExeSuffix}"; string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable); - Command.Create(selfContainedExecutableFullPath, new string[] { }) - .CaptureStdOut() + new RunExeCommand(Log, selfContainedExecutableFullPath) .Execute() .Should() .Pass() @@ -140,8 +139,7 @@ public void PublishWithRuntimeIdentifier(bool publishNoBuild) var selfContainedExecutable = $"{testProject.Name}{Constants.ExeSuffix}"; string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable); - Command.Create(selfContainedExecutableFullPath, new string[] { }) - .CaptureStdOut() + new RunExeCommand(Log, selfContainedExecutableFullPath) .Execute() .Should() .Pass()