Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 3de5eb9

Browse files
committed
Fix race in telemetry msbuild arg tests
1 parent 62c3798 commit 3de5eb9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/dotnet-msbuild.Tests/GivenDotnetMSBuildBuildsProjects.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Reflection;
88
using System.Runtime.InteropServices;
99
using FluentAssertions;
10+
using Microsoft.DotNet.Cli;
1011
using Microsoft.DotNet.Configurer;
1112
using Microsoft.DotNet.Tools.MSBuild;
1213
using Microsoft.DotNet.Tools.Test.Utilities;
@@ -17,6 +18,9 @@
1718
using System.Diagnostics;
1819
using System.Threading;
1920

21+
// There are tests which modify static Telemetry.CurrentSessionId and they cannot run in parallel
22+
[assembly: CollectionBehavior(DisableTestParallelization = true)]
23+
2024
namespace Microsoft.DotNet.Cli.MSBuild.Tests
2125
{
2226
public class GivenDotnetMSBuildBuildsProjects : TestBase
@@ -127,7 +131,7 @@ public void WhenTelemetryIsEnabledTheLoggerIsAddedToTheCommandLine()
127131
{
128132
Telemetry telemetry;
129133
string[] allArgs = GetArgsForMSBuild(() => true, out telemetry);
130-
// telemetry will still be disabled if environmental variable is set
134+
// telemetry will still be disabled if environment variable is set
131135
if (telemetry.Enabled)
132136
{
133137
allArgs.Should().NotBeNull();
@@ -158,6 +162,7 @@ private string[] GetArgsForMSBuild(Func<bool> sentinelExists)
158162

159163
private string[] GetArgsForMSBuild(Func<bool> sentinelExists, out Telemetry telemetry)
160164
{
165+
Telemetry.CurrentSessionId = null; // reset static session id modified by telemetry constructor
161166
telemetry = new Telemetry(new MockNuGetCacheSentinel(sentinelExists));
162167

163168
MSBuildForwardingApp msBuildForwardingApp = new MSBuildForwardingApp(Enumerable.Empty<string>());

0 commit comments

Comments
 (0)