Ignore "Platform linker not found" in local runs
This commit is contained in:
Родитель
fc74903734
Коммит
e1f1d4d1dc
|
@ -9,6 +9,7 @@ using BenchmarkDotNet.Tests.Loggers;
|
|||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using System.Collections.Generic;
|
||||
using BenchmarkDotNet.IntegrationTests.Xunit;
|
||||
using BenchmarkDotNet.Reports;
|
||||
|
||||
namespace BenchmarkDotNet.IntegrationTests
|
||||
|
@ -70,6 +71,8 @@ namespace BenchmarkDotNet.IntegrationTests
|
|||
|
||||
Assert.True(summary.Reports.Any(), "The \"Summary\" should contain at least one \"BenchmarkReport\" in the \"Reports\" collection");
|
||||
|
||||
summary.CheckPlatformLinkerIssues();
|
||||
|
||||
Assert.True(summary.Reports.All(r => r.BuildResult.IsBuildSuccess),
|
||||
"The following benchmarks have failed to build: " +
|
||||
string.Join(", ", summary.Reports.Where(r => !r.BuildResult.IsBuildSuccess).Select(r => r.BenchmarkCase.DisplayInfo)));
|
||||
|
|
|
@ -5,10 +5,16 @@ namespace BenchmarkDotNet.IntegrationTests
|
|||
{
|
||||
internal static class ContinuousIntegration
|
||||
{
|
||||
private static bool IsGitHubActions() => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTION"));
|
||||
|
||||
private static bool IsAppVeyor() => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPVEYOR"));
|
||||
|
||||
internal static bool IsGitHubActionsOnWindows()
|
||||
=> RuntimeInformation.IsWindows() && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTION"));
|
||||
=> RuntimeInformation.IsWindows() && IsGitHubActions();
|
||||
|
||||
internal static bool IsAppVeyorOnWindows()
|
||||
=> RuntimeInformation.IsWindows() && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPVEYOR"));
|
||||
=> RuntimeInformation.IsWindows() && IsAppVeyor();
|
||||
|
||||
internal static bool IsLocalRun() => !IsGitHubActions() && !IsAppVeyor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Configs;
|
||||
using BenchmarkDotNet.Environments;
|
||||
using BenchmarkDotNet.IntegrationTests.Xunit;
|
||||
using BenchmarkDotNet.Jobs;
|
||||
using BenchmarkDotNet.Portability;
|
||||
using BenchmarkDotNet.Tests.XUnit;
|
||||
|
@ -34,7 +35,17 @@ namespace BenchmarkDotNet.IntegrationTests
|
|||
.WithToolchain(toolchain)
|
||||
.WithEnvironmentVariable(NativeAotBenchmark.EnvVarKey, IsAvx2Supported().ToString().ToLower()));
|
||||
|
||||
CanExecute<NativeAotBenchmark>(config);
|
||||
try
|
||||
{
|
||||
CanExecute<NativeAotBenchmark>(config);
|
||||
}
|
||||
catch (MisconfiguredEnvironmentException e)
|
||||
{
|
||||
if (ContinuousIntegration.IsLocalRun())
|
||||
Output.WriteLine(e.SkipMessage);
|
||||
else
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAvx2Supported()
|
||||
|
|
|
@ -14,7 +14,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using BenchmarkDotNet.Environments;
|
||||
using BenchmarkDotNet.IntegrationTests.Xunit;
|
||||
using BenchmarkDotNet.Portability;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
@ -49,6 +49,19 @@ namespace BenchmarkDotNet.IntegrationTests
|
|||
var config = CreateConfig(toolchain);
|
||||
|
||||
var summary = BenchmarkRunner.Run<CompletedWorkItemCount>(config);
|
||||
try
|
||||
{
|
||||
summary.CheckPlatformLinkerIssues();
|
||||
}
|
||||
catch (MisconfiguredEnvironmentException e)
|
||||
{
|
||||
if (ContinuousIntegration.IsLocalRun())
|
||||
{
|
||||
output.WriteLine(e.SkipMessage);
|
||||
return;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
AssertStats(summary, new Dictionary<string, (string metricName, double expectedValue)>
|
||||
{
|
||||
|
@ -77,6 +90,19 @@ namespace BenchmarkDotNet.IntegrationTests
|
|||
var config = CreateConfig(toolchain);
|
||||
|
||||
var summary = BenchmarkRunner.Run<LockContentionCount>(config);
|
||||
try
|
||||
{
|
||||
summary.CheckPlatformLinkerIssues();
|
||||
}
|
||||
catch (MisconfiguredEnvironmentException e)
|
||||
{
|
||||
if (ContinuousIntegration.IsLocalRun())
|
||||
{
|
||||
output.WriteLine(e.SkipMessage);
|
||||
return;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
AssertStats(summary, new Dictionary<string, (string metricName, double expectedValue)>
|
||||
{
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using System.Linq;
|
||||
using BenchmarkDotNet.Reports;
|
||||
|
||||
namespace BenchmarkDotNet.IntegrationTests.Xunit
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static void CheckPlatformLinkerIssues(this Summary summary)
|
||||
{
|
||||
if (summary.Reports.Any(r =>
|
||||
!r.BuildResult.IsBuildSuccess &&
|
||||
r.BuildResult.ErrorMessage.Contains("Platform linker not found")))
|
||||
throw new MisconfiguredEnvironmentException("Failed to build benchmarks because the platform linker not found");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace BenchmarkDotNet.IntegrationTests.Xunit
|
||||
{
|
||||
public class MisconfiguredEnvironmentException : Exception
|
||||
{
|
||||
public MisconfiguredEnvironmentException(string message) : base(message) { }
|
||||
|
||||
public string SkipMessage => $"Skip this test because the environment is misconfigured ({Message})";
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче