Skip to content

Commit 3899081

Browse files
Suppress dependency rebuilding in integration tests on windows+net7.0
1 parent c78b7d6 commit 3899081

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Linq;
3+
4+
namespace BenchmarkDotNet.Helpers;
5+
6+
internal static class XUnitHelper
7+
{
8+
public static Lazy<bool> IsIntegrationTest =
9+
new (() => AppDomain.CurrentDomain.GetAssemblies().Any(assembly => assembly.GetName().Name == "BenchmarkDotNet.IntegrationTests"));
10+
}

src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommand.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text;
55
using BenchmarkDotNet.Characteristics;
66
using BenchmarkDotNet.Extensions;
7+
using BenchmarkDotNet.Helpers;
78
using BenchmarkDotNet.Jobs;
89
using BenchmarkDotNet.Loggers;
910
using BenchmarkDotNet.Portability;
@@ -73,9 +74,21 @@ public BuildResult RestoreThenBuild()
7374
if (!restoreResult.IsSuccess)
7475
return BuildResult.Failure(GenerateResult, restoreResult.AllInformation);
7576

76-
var buildResult = BuildNoRestore();
77-
if (!buildResult.IsSuccess && RetryFailedBuildWithNoDeps) // if we fail to do the full build, we try with --no-dependencies
77+
// On our CI (Windows+.NET 7), Integration tests take to much time because each benchmark run rebuilds the BenchmarkDotNet itself.
78+
// To reduce the total duration of the CI workflows, we build all the projects without dependencies
79+
bool forceNoDependencies = XUnitHelper.IsIntegrationTest.Value &&
80+
RuntimeInformation.IsWindows() &&
81+
RuntimeInformation.IsNetCore;
82+
83+
DotNetCliCommandResult buildResult;
84+
if (forceNoDependencies)
7885
buildResult = BuildNoRestoreNoDependencies();
86+
else
87+
{
88+
buildResult = BuildNoRestore();
89+
if (!buildResult.IsSuccess && RetryFailedBuildWithNoDeps) // if we fail to do the full build, we try with --no-dependencies
90+
buildResult = BuildNoRestoreNoDependencies();
91+
}
7992

8093
return buildResult.ToBuildResult(GenerateResult);
8194
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using BenchmarkDotNet.Helpers;
2+
using Xunit;
3+
4+
namespace BenchmarkDotNet.IntegrationTests;
5+
6+
public class IntegrationTestSetupTests
7+
{
8+
[Fact]
9+
public void IntegrationTestsAreDetected() => Assert.True(XUnitHelper.IsIntegrationTest.Value);
10+
}

0 commit comments

Comments
 (0)