From: Pieter-Jan Briers Date: Tue, 22 Jul 2025 14:22:50 +0000 (+0200) Subject: Fix RoundEndTest obsolete warnings (#39133) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=65b4b41928adca08247227844d376567c13374d6;p=space-station-14.git Fix RoundEndTest obsolete warnings (#39133) We love using low-leaving threading APIs incorrectly. --- diff --git a/Content.IntegrationTests/Tests/RoundEndTest.cs b/Content.IntegrationTests/Tests/RoundEndTest.cs index 6978085640..5de6de381d 100644 --- a/Content.IntegrationTests/Tests/RoundEndTest.cs +++ b/Content.IntegrationTests/Tests/RoundEndTest.cs @@ -1,4 +1,3 @@ -using System.Threading; using Content.Server.GameTicking; using Content.Server.RoundEnd; using Content.Shared.CCVar; @@ -22,7 +21,7 @@ namespace Content.IntegrationTests.Tests private void OnRoundEnd(RoundEndSystemChangedEvent ev) { - Interlocked.Increment(ref RoundCount); + RoundCount += 1; } } @@ -127,13 +126,17 @@ namespace Content.IntegrationTests.Tests async Task WaitForEvent() { - var timeout = Task.Delay(TimeSpan.FromSeconds(10)); - var currentCount = Thread.VolatileRead(ref sys.RoundCount); - while (currentCount == Thread.VolatileRead(ref sys.RoundCount) && !timeout.IsCompleted) + const int maxTicks = 60; + var currentCount = sys.RoundCount; + for (var i = 0; i < maxTicks; i++) { - await pair.RunTicksSync(5); + if (currentCount != sys.RoundCount) + return; + + await pair.RunTicksSync(1); } - if (timeout.IsCompleted) throw new TimeoutException("Event took too long to trigger"); + + throw new TimeoutException("Event took too long to trigger"); } // Need to clean self up