Skip to content

Commit 8beedac

Browse files
author
Arin Ghazarian
authored
Merge pull request #1313 from github/improve-int-test-outputs
Improve integration test console output
2 parents 8175b52 + d00db0d commit 8beedac

File tree

7 files changed

+489
-824
lines changed

7 files changed

+489
-824
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ jobs:
250250
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
251251
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
252252
LD_LIBRARY_PATH: '$LD_LIBRARY_PATH:${{ github.workspace }}/src/OctoshiftCLI.IntegrationTests/bin/Debug/net8.0/runtimes/ubuntu.18.04-x64/native'
253-
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" /p:VersionPrefix=9.9
253+
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" --logger "console;verbosity=normal" /p:VersionPrefix=9.9
254254

255255
- name: Publish Integration Test Results
256256
uses: EnricoMi/publish-unit-test-result-action@v2

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ jobs:
175175
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
176176
GEI_DEBUG_MODE: 'true'
177177
LD_LIBRARY_PATH: '$LD_LIBRARY_PATH:${{ github.workspace }}/src/OctoshiftCLI.IntegrationTests/bin/Debug/net8.0/runtimes/ubuntu.18.04-x64/native'
178-
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" /p:VersionPrefix=9.9
178+
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" --logger "console;verbosity=normal" /p:VersionPrefix=9.9
179179

180180
- name: Publish Integration Test Results
181181
uses: EnricoMi/publish-unit-test-result-action@v2

ThirdPartyNotices.txt

Lines changed: 455 additions & 784 deletions
Large diffs are not rendered by default.

src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="CliWrap" Version="3.6.7" />
1011
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1112
<PackageReference Include="JunitXml.TestLogger" Version="3.0.134" />
1213
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
1314
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
1415
<PackageReference Include="Moq" Version="4.20.69" />
15-
<PackageReference Include="xunit" Version="2.5.0" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
16+
<PackageReference Include="xunit" Version="2.9.2" />
17+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1718
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1819
<PrivateAssets>all</PrivateAssets>
1920
</PackageReference>
@@ -27,4 +28,10 @@
2728
<ProjectReference Include="..\Octoshift\Octoshift.csproj" />
2829
</ItemGroup>
2930

31+
<ItemGroup>
32+
<None Update="xunit.runner.json">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</None>
35+
</ItemGroup>
36+
3037
</Project>

src/OctoshiftCLI.IntegrationTests/TestHelper.cs

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;
43
using System.IO;
54
using System.Linq;
65
using System.Runtime.InteropServices;
76
using System.Threading.Tasks;
87
using Azure.Storage.Blobs;
8+
using CliWrap;
99
using FluentAssertions;
1010
using Newtonsoft.Json.Linq;
1111
using OctoshiftCLI.Services;
@@ -526,7 +526,7 @@ public static string GetOsName()
526526
: throw new InvalidOperationException("Could not determine OS");
527527
}
528528

529-
public async Task RunCliMigration(string generateScriptCommand, string cliName, IDictionary<string, string> tokens)
529+
public async Task RunCliMigration(string generateScriptCommand, string cliName, IReadOnlyDictionary<string, string> tokens)
530530
{
531531
await RunCliCommand(generateScriptCommand, cliName, tokens);
532532
LogMigrationScript("migrate.ps1");
@@ -541,51 +541,34 @@ private void LogMigrationScript(string filename)
541541
_output.WriteLine(scriptContents);
542542
}
543543

544-
public async Task RunPowershellScript(string script, IDictionary<string, string> tokens) =>
544+
public async Task RunPowershellScript(string script, IReadOnlyDictionary<string, string> tokens) =>
545545
await RunShellCommand($"-File {Path.Join(GetOsDistPath(), script)}", "pwsh", GetOsDistPath(), tokens);
546546

547-
public async Task RunCliCommand(string command, string cliName, IDictionary<string, string> tokens) =>
547+
public async Task RunCliCommand(string command, string cliName, IReadOnlyDictionary<string, string> tokens) =>
548548
await RunShellCommand(command, cliName, GetOsDistPath(), tokens);
549549

550-
private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IDictionary<string, string> environmentVariables = null)
550+
private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IReadOnlyDictionary<string, string> environmentVariables = null)
551551
{
552-
var startInfo = new ProcessStartInfo
553-
{
554-
WorkingDirectory = workingDirectory ?? Directory.GetCurrentDirectory(),
555-
FileName = fileName,
556-
Arguments = command
557-
};
558-
559-
if (environmentVariables != null)
560-
{
561-
foreach (var token in environmentVariables)
562-
{
563-
if (startInfo.EnvironmentVariables.ContainsKey(token.Key))
564-
{
565-
startInfo.EnvironmentVariables[token.Key] = token.Value;
566-
}
567-
else
568-
{
569-
startInfo.EnvironmentVariables.Add(token.Key, token.Value);
570-
}
571-
}
572-
}
573-
574-
_output.WriteLine($"Running command: {startInfo.FileName} {startInfo.Arguments}");
552+
_output.WriteLine($"Running command: {fileName} {command}");
575553

576-
var p = Process.Start(startInfo);
577-
await p.WaitForExitAsync();
554+
var result = await Cli.Wrap(fileName)
555+
.WithArguments(command)
556+
.WithWorkingDirectory(workingDirectory ?? Directory.GetCurrentDirectory())
557+
.WithEnvironmentVariables(environmentVariables ?? new Dictionary<string, string>())
558+
.WithStandardOutputPipe(PipeTarget.ToDelegate(line => _output.WriteLine(line)))
559+
.WithStandardErrorPipe(PipeTarget.ToDelegate(line => _output.WriteLine(line)))
560+
.ExecuteAsync();
578561

579-
p.ExitCode.Should().Be(0, $"{fileName} should return an exit code of 0.");
562+
result.ExitCode.Should().Be(0, $"{fileName} should return an exit code of 0.");
580563
}
581564

582-
public async Task RunAdoToGithubCliMigration(string generateScriptCommand, IDictionary<string, string> tokens) =>
565+
public async Task RunAdoToGithubCliMigration(string generateScriptCommand, IReadOnlyDictionary<string, string> tokens) =>
583566
await RunCliMigration($"ado2gh {generateScriptCommand}", "gh", tokens);
584567

585-
public async Task RunGeiCliMigration(string generateScriptCommand, IDictionary<string, string> tokens) =>
568+
public async Task RunGeiCliMigration(string generateScriptCommand, IReadOnlyDictionary<string, string> tokens) =>
586569
await RunCliMigration($"gei {generateScriptCommand}", "gh", tokens);
587570

588-
public async Task RunBbsCliMigration(string generateScriptCommand, IDictionary<string, string> tokens) =>
571+
public async Task RunBbsCliMigration(string generateScriptCommand, IReadOnlyDictionary<string, string> tokens) =>
589572
await RunCliMigration($"bbs2gh {generateScriptCommand}", "gh", tokens);
590573

591574
public static string GetOsDistPath()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3+
"showLiveOutput": true
4+
}

src/OctoshiftCLI.Tests/OctoshiftCLI.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
2222

2323
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
24-
<PackageReference Include="xunit" Version="2.5.0" />
25-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
24+
<PackageReference Include="xunit" Version="2.9.2" />
25+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
2626
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2727
<PrivateAssets>all</PrivateAssets>
2828
</PackageReference>

0 commit comments

Comments
 (0)