diff --git a/source/Octopus.Tentacle.Tests.Integration/Octopus.Tentacle.Tests.Integration.csproj b/source/Octopus.Tentacle.Tests.Integration/Octopus.Tentacle.Tests.Integration.csproj index 97015e791..373c15876 100644 --- a/source/Octopus.Tentacle.Tests.Integration/Octopus.Tentacle.Tests.Integration.csproj +++ b/source/Octopus.Tentacle.Tests.Integration/Octopus.Tentacle.Tests.Integration.csproj @@ -24,7 +24,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/source/Octopus.Tentacle.Tests.Integration/Support/TentacleBuilder.cs b/source/Octopus.Tentacle.Tests.Integration/Support/TentacleBuilder.cs index 952ed4bcd..7384f566b 100644 --- a/source/Octopus.Tentacle.Tests.Integration/Support/TentacleBuilder.cs +++ b/source/Octopus.Tentacle.Tests.Integration/Support/TentacleBuilder.cs @@ -9,12 +9,11 @@ using System.Threading.Tasks; using Autofac; using Autofac.Util; -using CliWrap; -using CliWrap.Exceptions; using Microsoft.Win32; using Nito.AsyncEx; using Nito.AsyncEx.Interop; using NUnit.Framework; +using Octopus.Shellfish; using Octopus.Tentacle.CommonTestUtils; using Octopus.Tentacle.Configuration; using Octopus.Tentacle.Tests.Integration.Util; @@ -489,22 +488,21 @@ async Task RunCommandOutOfProcess( ILogger logger, CancellationToken cancellationToken) { - async Task ProcessLogs(string s, CancellationToken ct) + void ProcessLogs(string s) { - await Task.CompletedTask; logger.Information($"[{commandName}] " + s); commandOutput(s); } try { - var commandResult = await RetryHelper.RetryAsync( - () => Cli.Wrap(targetFilePath) + var commandResult = await RetryHelper.RetryAsync( + () => new ShellCommand(targetFilePath) .WithArguments(args) .WithEnvironmentVariables(environmentVariables) .WithWorkingDirectory(tmp.DirectoryPath) - .WithStandardOutputPipe(PipeTarget.ToDelegate(ProcessLogs)) - .WithStandardErrorPipe(PipeTarget.ToDelegate(ProcessLogs)) + .WithStdOutTarget(ProcessLogs) + .WithStdErrTarget(ProcessLogs) .ExecuteAsync(cancellationToken)); if (cancellationToken.IsCancellationRequested) return; diff --git a/source/Octopus.Tentacle.Tests.Integration/TentacleCommandLineTests.cs b/source/Octopus.Tentacle.Tests.Integration/TentacleCommandLineTests.cs index fba7ceedb..6977faea8 100644 --- a/source/Octopus.Tentacle.Tests.Integration/TentacleCommandLineTests.cs +++ b/source/Octopus.Tentacle.Tests.Integration/TentacleCommandLineTests.cs @@ -7,12 +7,11 @@ using System.Security.Principal; using System.Text; using System.Threading.Tasks; -using CliWrap; -using CliWrap.Exceptions; using FluentAssertions; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NUnit.Framework; +using Octopus.Shellfish; using Octopus.Tentacle.CommonTestUtils; using Octopus.Tentacle.Tests.Integration.Support; using Octopus.Tentacle.Tests.Integration.Support.TestAttributes; @@ -119,7 +118,7 @@ public async Task VersionCommandTextFormat(TentacleConfigurationTestCase tc) var expectedVersion = GetVersionInfo(tc); - stdout.Should().Be(expectedVersion.ProductVersion, "The version command should print the informational version as text"); + stdout.TrimEnd().Should().Be(expectedVersion.ProductVersion, "The version command should print the informational version as text"); stderr.Should().BeNullOrEmpty(); } @@ -267,7 +266,8 @@ public async Task CommandSpecificHelpAsJsonLooksSensibleToHumans(TentacleConfigu ""Description"": ""Show detailed help for this command"" } ] -}"); +} +"); } [Test] @@ -359,7 +359,7 @@ public async Task ShowThumbprintCommandText(TentacleConfigurationTestCase tc) "show-thumbprint", $"--instance={clientAndTentacle.RunningTentacle.InstanceName}"); exitCode.Should().Be(0, $"we expected the command to succeed.\r\nStdErr: '{stderr}'\r\nStdOut: '{stdout}'"); - stdout.Should().Be(TestCertificates.TentaclePublicThumbprint, "the thumbprint should be written directly to stdout"); + stdout.TrimEnd().Should().Be(TestCertificates.TentaclePublicThumbprint, "the thumbprint should be written directly to stdout"); stderr.Should().BeNullOrEmpty(); } @@ -377,7 +377,7 @@ public async Task ShowThumbprintCommandJson(TentacleConfigurationTestCase tc) "show-thumbprint", $"--instance={clientAndTentacle.RunningTentacle.InstanceName}", "--format=json"); exitCode.Should().Be(0, $"we expected the command to succeed.\r\nStdErr: '{stderr}'\r\nStdOut: '{stdout}'"); - stdout.Should().Be(JsonConvert.SerializeObject(new { Thumbprint = TestCertificates.TentaclePublicThumbprint }), "the thumbprint should be written directly to stdout as JSON"); + stdout.TrimEnd().Should().Be(JsonConvert.SerializeObject(new { Thumbprint = TestCertificates.TentaclePublicThumbprint }), "the thumbprint should be written directly to stdout as JSON"); stderr.Should().BeNullOrEmpty(); } @@ -727,12 +727,11 @@ FileVersionInfo GetVersionInfo(TentacleConfigurationTestCase tentacleConfigurati var output = new StringBuilder(); var errorOut = new StringBuilder(); - var result = await RetryHelper.RetryAsync( - () => Cli.Wrap(tentacleExe) + var result = await RetryHelper.RetryAsync( + () => new ShellCommand(tentacleExe) .WithArguments(arguments) - .WithValidation(CommandResultValidation.None) - .WithStandardOutputPipe(PipeTarget.ToStringBuilder(output)) - .WithStandardErrorPipe(PipeTarget.ToStringBuilder(errorOut)) + .WithStdOutTarget(output) + .WithStdErrTarget(errorOut) .WithEnvironmentVariables(environmentVariablesToRunTentacleWith) .ExecuteAsync(CancellationToken)); diff --git a/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj b/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj index 675416bb1..052bf9809 100644 --- a/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj +++ b/source/Octopus.Tentacle.Tests/Octopus.Tentacle.Tests.csproj @@ -51,7 +51,7 @@ - + diff --git a/source/Tentacle.sln.DotSettings b/source/Tentacle.sln.DotSettings index 0e7802a6d..2c88b318a 100644 --- a/source/Tentacle.sln.DotSettings +++ b/source/Tentacle.sln.DotSettings @@ -183,6 +183,7 @@ True True True + True True True True