Skip to content

Commit 617f678

Browse files
authored
Fix test to take warning MSB5018 (#11499)
Fixes #9176 Context Occasionally temp files fail to delete because of virus checkers, so generate MSB5018 warning. The commit d7788d6#diff-3abd8382aac3bdfa59d5c1ca41dd089795d6ca539a00b3c50eab4fd6a0996314 including string lockedFileMessage = LockCheck.GetLockedFileMessage(fileName); doesn't output the related process. Changes Made Add the warning MSB5018
1 parent 1ab203b commit 617f678

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Tasks.UnitTests/Exec_Tests.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,20 @@ public void Timeout()
171171
Assert.Equal(expectedExitCode, exec.ExitCode);
172172
((MockEngine)exec.BuildEngine).AssertLogContains("MSB5002");
173173
int warningsCount = ((MockEngine)exec.BuildEngine).Warnings;
174-
warningsCount.ShouldBe(1,
174+
if (warningsCount == 1)
175+
{
176+
warningsCount.ShouldBe(1,
175177
$"Expected 1 warning, encountered {warningsCount}: " + string.Join(",",
176178
((MockEngine)exec.BuildEngine).WarningEvents.Select(w => w.Message)));
179+
}
180+
else
181+
{
182+
// Occasionally temp files fail to delete because of virus checkers, so generate MSB5018 warning
183+
((MockEngine)exec.BuildEngine).AssertLogContains("MSB5018");
184+
warningsCount.ShouldBe(2,
185+
$"Expected 2 warnings, encountered {warningsCount}: " + string.Join(",",
186+
((MockEngine)exec.BuildEngine).WarningEvents.Select(w => w.Message)));
187+
}
177188

178189
// ToolTask does not log an error on timeout.
179190
Assert.Equal(0, ((MockEngine)exec.BuildEngine).Errors);

0 commit comments

Comments
 (0)