]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix RoundEndTest obsolete warnings (#39133)
authorPieter-Jan Briers <pieterjan.briers+git@gmail.com>
Tue, 22 Jul 2025 14:22:50 +0000 (16:22 +0200)
committerGitHub <noreply@github.com>
Tue, 22 Jul 2025 14:22:50 +0000 (10:22 -0400)
We love using low-leaving threading APIs incorrectly.

Content.IntegrationTests/Tests/RoundEndTest.cs

index 6978085640676e93156f2e27519623e90199624c..5de6de381de36f965bbf00dfd3e5f09a645d2615 100644 (file)
@@ -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