Skip to content

Commit 6a5059d

Browse files
SimaTianCopilot
andcommitted
Apply council review: validate outputs in concurrent tests, compare items in parity tests
- Concurrent tests now validate per-thread output values (not just exception-free) - Parity tests compare output item counts (ProcessedContentItems, CopyLocalItems, FileWrites, ResolvedAssets) - ProduceContentAssets_EmptyDependencies_Succeeds now sets TaskEnvironment Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2dc9975 commit 6a5059d

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAProduceContentAssetsMultiThreading.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public void ItProducesSameResultsRegardlessOfCwd()
114114
"task should return the same result regardless of CWD");
115115
engine1.Errors.Count.Should().Be(engine2.Errors.Count,
116116
"error count should be the same in both environments");
117+
task1.ProcessedContentItems.Length.Should().Be(task2.ProcessedContentItems.Length,
118+
"ProcessedContentItems count should be identical regardless of CWD");
119+
task1.CopyLocalItems.Length.Should().Be(task2.CopyLocalItems.Length,
120+
"CopyLocalItems count should be identical regardless of CWD");
121+
task1.FileWrites.Length.Should().Be(task2.FileWrites.Length,
122+
"FileWrites count should be identical regardless of CWD");
117123
}
118124
finally
119125
{

src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAResolveCopyLocalAssetsMultiThreading.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ public void ItProducesSameResultsInMultiProcessAndMultiThreadedEnvironments()
109109
"task should return the same result regardless of CWD");
110110
engine1.Errors.Count.Should().Be(engine2.Errors.Count,
111111
"error count should be identical in both environments");
112+
task1.ResolvedAssets.Length.Should().Be(task2.ResolvedAssets.Length,
113+
"ResolvedAssets count should be identical regardless of CWD");
112114
}
113115
finally
114116
{

src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAttributeOnlyTasksGroup6.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ public void ProduceContentAssets_EmptyDependencies_Succeeds()
413413
{
414414
BuildEngine = new MockBuildEngine(),
415415
ContentFileDependencies = Array.Empty<ITaskItem>(),
416-
ProjectLanguage = "C#"
416+
ProjectLanguage = "C#",
417+
TaskEnvironment = TaskEnvironmentHelper.CreateForTest()
417418
};
418419

419420
var result = task.Execute();
@@ -497,6 +498,11 @@ public async System.Threading.Tasks.Task GetDefaultPlatformTargetForNetFramework
497498

498499
startGate.Wait();
499500
task.Execute();
501+
502+
if (task.DefaultPlatformTarget != "AnyCPU")
503+
{
504+
errors.Add($"Thread {idx}: Expected 'AnyCPU' but got '{task.DefaultPlatformTarget}'");
505+
}
500506
}
501507
catch (Exception ex)
502508
{
@@ -536,6 +542,11 @@ public async System.Threading.Tasks.Task GetEmbeddedApphostPaths_ConcurrentExecu
536542

537543
startGate.Wait();
538544
task.Execute();
545+
546+
if (task.EmbeddedApphostPaths == null || task.EmbeddedApphostPaths.Length != 1)
547+
{
548+
errors.Add($"Thread {idx}: Expected 1 path but got {task.EmbeddedApphostPaths?.Length}");
549+
}
539550
}
540551
catch (Exception ex)
541552
{
@@ -573,6 +584,11 @@ public async System.Threading.Tasks.Task GetNuGetShortFolderName_ConcurrentExecu
573584

574585
startGate.Wait();
575586
task.Execute();
587+
588+
if (task.NuGetShortFolderName != "net8.0")
589+
{
590+
errors.Add($"Thread {idx}: Expected 'net8.0' but got '{task.NuGetShortFolderName}'");
591+
}
576592
}
577593
catch (Exception ex)
578594
{

0 commit comments

Comments
 (0)