Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<PackageVersion Include="ktsu.CredentialCache" Version="1.3.21" />
<PackageVersion Include="ktsu.Essentials" Version="2.0.0" />
<PackageVersion Include="ktsu.Essentials.FileSystemProviders.Native" Version="2.0.0" />
<PackageVersion Include="ktsu.RunCommand" Version="1.5.0" />
<PackageVersion Include="ktsu.Semantics.Paths" Version="3.0.1" />
<PackageVersion Include="ktsu.Semantics.Strings" Version="3.0.1" />
<PackageVersion Include="ktsu.RunCommand" Version="1.9.5" />
<PackageVersion Include="ktsu.Semantics.Paths" Version="5.11.2" />
<PackageVersion Include="ktsu.Semantics.Strings" Version="5.11.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2" />
<PackageVersion Include="Octokit" Version="14.0.0" />
Expand Down
39 changes: 39 additions & 0 deletions GitIntegration.Test/Execution/RunCommandGitProcessRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,45 @@
Assert.AreEqual("0-C", result.StandardOutput.Trim());
}

[TestMethod]
public async Task CapturesAllOutputWrittenJustBeforeTheProcessExitsAsync()
{
// ktsu.RunCommand before 1.8.0 stopped reading when the process exited and then made one
// final read, so whatever was still in the pipe past that read was dropped: git output
// over ~8 KiB came back cut at 8,192 characters a few percent of the time, and Patch()
// returned short hunks (ktsu-dev/GitIntegration#127). A command that writes well over that
// in one burst and exits at once leaves the most in the pipe at exit, and it is repeated
// because whether a read loses the race is decided by scheduling.
const int Length = 60000;
string executable;
string[] arguments;

if (OperatingSystem.IsWindows())
{
executable = "powershell";
arguments = ["-NoProfile", "-Command", $"[Console]::Out.Write('a' * {Length})"];
}
else
{
executable = "sh";
arguments = ["-c", $"head -c {Length} /dev/zero | tr '\\0' a"];
}

RunCommandGitProcessRunner runner = new(new GitOptions { ExecutablePath = executable });
string expected = new('a', Length);

for (int iteration = 0; iteration < 100; iteration++)
{
GitProcessResult result = await runner.RunAsync(
new GitProcessRequest { Arguments = arguments },
TestContext.CancellationTokenSource.Token).ConfigureAwait(false);

Check warning on line 320 in GitIntegration.Test/Execution/RunCommandGitProcessRunnerTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use 'TestContext.CancellationToken' instead of 'TestContext.CancellationTokenSource.Token'

See more on https://sonarcloud.io/project/issues?id=ktsu-dev_GitIntegration&issues=AaEZ0KNX3MSjhg4Injcf&open=AaEZ0KNX3MSjhg4Injcf&pullRequest=198

Assert.AreEqual(0, result.ExitCode);
Assert.AreEqual(expected.Length, result.StandardOutput.Length, $"Run {iteration} lost output.");
Assert.AreEqual(expected, result.StandardOutput, $"Run {iteration} returned different output.");
}
}

[TestMethod]
public void EnvironmentOverlayForcesNonInteractiveEnglishGit()
{
Expand Down
Loading