From e9acaff14097df5eedbdf4352422452b7f3ba2eb Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Thu, 7 Sep 2023 03:05:04 +0200
Subject: [PATCH] [MIRROR] Attempts to fix the leash unit test CI failures [MDB
IGNORE] (#23556)
* Attempts to fix the leash unit test CI failures (#78157)
## About The Pull Request
Fixes https://github.com/tgstation/tgstation/issues/77704
Fixes https://github.com/Skyrat-SS13/Skyrat-tg/issues/23467
Fixes https://github.com/Skyrat-SS13/Skyrat-tg/issues/23511
What it says on the tin. This has started causing CI failures with the
Tramstation test in almost every single PR downstream and it's gotten to
the point where it's become a major headache.
I don't know why it's happening only only on Tramstation, or why it's
happening at all-- but I will say it instantly began ramping up in
frequency immediately after merging
https://github.com/tgstation/tgstation/pull/75924 , which was the same
PR that was also causing the progressbar harddels previously to crop up
every time @ LemonInTheDark .
This attempts to fix it by doing 2 things:
~~1) Make sure the `COMSIG_LEASH_PATH_COMPLETE` always gets sent, which
will prevent needless false 'timeouts' whenever every iteration of the
check_distance() loop returns early. Now it will only timeout when it
actually times out.~~
1) Increases the timeout timer to 80 seconds. Why so long? Well, I've
looked at a number of individual CI failures and it looks like it tries
to complete the path somewhere between 40-75 seconds after the time out
failure. Most of the time it should not take this long though and will
just finish right away as normal.
Timeouts with timestamps shown here so you can see
what I am talking about


And here


And here


2) Moves the priority of the test down so it happens later, with the
other long tests. This might even fix the issue on its own--haven't seen
the test take more than 0.1s to complete so far in any of my runs. Maybe
things just needed some more time to load?
So far I've done about 10 test runs and haven't seen a single timeout
with these two changes. I'm fairly confident the issue is fixed but
we'll see.
Test functioning:

## Why It's Good For The Game
Stops a PR blocking spurious CI failure.
## Changelog
:cl:
fix: leash unit test will time out less often and increases the timer
until it is considered 'timed out', to reduce false CI failures
/:cl:
* Attempts to fix the leash unit test CI failures
---------
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
---
code/modules/unit_tests/leash.dm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/modules/unit_tests/leash.dm b/code/modules/unit_tests/leash.dm
index 2372ebca7df..a3d919be12f 100644
--- a/code/modules/unit_tests/leash.dm
+++ b/code/modules/unit_tests/leash.dm
@@ -1,5 +1,6 @@
/datum/unit_test/leash
abstract_type = /datum/unit_test/leash
+ priority = TEST_LONGER
var/atom/movable/owner
var/atom/movable/pet
@@ -55,7 +56,7 @@
var/timed_out = FALSE
/datum/leash_wait/New()
- addtimer(VARSET_CALLBACK(src, timed_out, TRUE), 1 SECONDS)
+ addtimer(VARSET_CALLBACK(src, timed_out, TRUE), 80 SECONDS)
/datum/leash_wait/proc/completed()
completed = TRUE