Skip to content

Commit 622b413

Browse files
authored
chore: reduce ci log messages (#3300)
1 parent 8b3b520 commit 622b413

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

‎build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public class UnitTestRunner(BuildContext context)
3232
private DirectoryPath TestOutputDirectory { get; } = context.RootDirectory
3333
.Combine("TestResults");
3434

35-
private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tfm)
35+
private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tfm, string consoleLogVerbosity)
3636
{
3737
var settings = new DotNetTestSettings
3838
{
3939
Configuration = context.BuildConfiguration,
4040
Framework = tfm,
4141
NoBuild = true,
4242
NoRestore = true,
43-
Loggers = new[] { "trx", $"trx;LogFileName={logFile.FullPath}", "console;verbosity=detailed" },
43+
Loggers = ["trx", $"trx;LogFileName={logFile.FullPath}", $"console;verbosity={consoleLogVerbosity}"],
4444
EnvironmentVariables =
4545
{
4646
["Platform"] = "" // force the tool to not look for the .dll in platform-specific directory
@@ -51,11 +51,15 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf
5151

5252
private void RunTests(FilePath projectFile, string alias, string tfm)
5353
{
54+
var consoleLogVerbosity = projectFile == AnalyzerTestsProjectFile
55+
? "minimal" // Show logs when test failed only.
56+
: "detailed"; // Show detailed logs including stdout.
57+
5458
var os = Utils.GetOs();
5559
var arch = RuntimeInformation.OSArchitecture.ToString().ToLower();
5660
var trxFileName = $"{os}({arch})-{alias}-{tfm}.trx";
5761
var trxFile = TestOutputDirectory.CombineWithFilePath(trxFileName);
58-
var settings = GetTestSettingsParameters(trxFile, tfm);
62+
var settings = GetTestSettingsParameters(trxFile, tfm, consoleLogVerbosity);
5963

6064
context.Information($"Run tests for {projectFile} ({tfm}), result file: '{trxFile}'");
6165
context.DotNetTest(projectFile.FullPath, settings);

‎tests/BenchmarkDotNet.Tests/Perfonar/PerfonarTests.cs‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,39 @@ public class PerfonarTests(ITestOutputHelper output)
1616
{
1717
[Theory]
1818
[MemberData(nameof(EntryDataKeys))]
19-
public Task PerfonarIndexTest(string key) => VerifyString(key, new PerfonarIndex(TableDataMap[key].RootEntry).Dump());
19+
public async Task PerfonarIndexTest(string key)
20+
{
21+
var content = new PerfonarIndex(TableDataMap[key].RootEntry).Dump();
22+
23+
try
24+
{
25+
await VerifyString(key, content);
26+
}
27+
catch
28+
{
29+
output.WriteLine(content);
30+
throw;
31+
}
32+
}
2033

2134
[Theory]
2235
[MemberData(nameof(EntryDataKeys))]
23-
public Task PerfonarTableTest(string key)
36+
public async Task PerfonarTableTest(string key)
2437
{
2538
var table = TableDataMap[key];
2639
string markdown = table.ToMarkdown(new PerfonarTableStyle());
2740
string json = LightJsonSerializer.Serialize(table.RootEntry, new LightJsonSettings { Indent = true });
28-
return VerifyString(key, markdown + "\n" + json);
41+
42+
var content = $"{markdown}\n{json}";
43+
try
44+
{
45+
await VerifyString(key, content);
46+
}
47+
catch
48+
{
49+
output.WriteLine(content);
50+
throw;
51+
}
2952
}
3053

3154
private static readonly IDictionary<string, PerfonarTable> TableDataMap = new Dictionary<string, PerfonarTable>
@@ -162,9 +185,8 @@ public Task PerfonarTableTest(string key)
162185

163186
private Task VerifyString(string key, string content)
164187
{
165-
output.WriteLine(content);
166188
var settings = VerifyHelper.Create("Perfonar");
167-
settings.UseParameters(key);
168-
return Verifier.Verify(content, settings);
189+
settings.UseParameters(key);
190+
return Verifier.Verify(content, settings);
169191
}
170192
}

0 commit comments

Comments
 (0)