From 6a0ee8a2c17372893b27a4bc88cb6cc89710062f Mon Sep 17 00:00:00 2001 From: Roxy <75404941+TealSeer@users.noreply.github.com> Date: Fri, 3 Jul 2026 01:20:24 -0400 Subject: [PATCH] Unsilence `log_mapping` messages in unit tests that don't meet `/datum/unit_test/maptest_log_mapping` criteria (#96780) --- code/__HELPERS/logging/debug.dm | 10 ++++++++-- code/_globalvars/_regexes.dm | 3 +++ code/modules/unit_tests/mapping.dm | 11 ----------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/code/__HELPERS/logging/debug.dm b/code/__HELPERS/logging/debug.dm index 0d0f9f72ead..0d86f1872fb 100644 --- a/code/__HELPERS/logging/debug.dm +++ b/code/__HELPERS/logging/debug.dm @@ -26,8 +26,14 @@ /// Logging for mapping errors /proc/log_mapping(text, skip_world_log) #ifdef UNIT_TESTS - GLOB.unit_test_mapping_logs += text - return + // Only add to fail list if AREACOORD was conveyed, and it's a station or mining z-level. + // This is due to mapping errors don't have coords being impossible to diagnose as a unit test, + // and various ruins frequently intentionally doing non-standard things. + if(GLOB.test_areacoord_regex.Find(text)) + var/z = text2num(GLOB.test_areacoord_regex.group[1]) + if(is_station_level(z) || is_mining_level(z)) + GLOB.unit_test_mapping_logs += text + return #endif #ifdef MAP_TEST message_admins("Mapping: [text]") diff --git a/code/_globalvars/_regexes.dm b/code/_globalvars/_regexes.dm index 934296fe1bc..b65a7b5050f 100644 --- a/code/_globalvars/_regexes.dm +++ b/code/_globalvars/_regexes.dm @@ -21,3 +21,6 @@ GLOBAL_DATUM_INIT(html_tags, /regex, regex(@"<.*?>", "g")) GLOBAL_DATUM_INIT(filename_forbidden_chars, /regex, regex(@{""|[\\\n\t/?%*:|<>]|\.\."}, "g")) GLOBAL_PROTECT(filename_forbidden_chars) // had to use the OR operator for quotes instead of putting them in the character class because it breaks the syntax highlighting otherwise. + +//Find AREACOORD() in log_mapping messages +GLOBAL_DATUM_INIT(test_areacoord_regex, /regex, regex(@"\(-?\d+,-?\d+,(-?\d+)\)")) diff --git a/code/modules/unit_tests/mapping.dm b/code/modules/unit_tests/mapping.dm index ffdd66e2f67..4a3393ddf95 100644 --- a/code/modules/unit_tests/mapping.dm +++ b/code/modules/unit_tests/mapping.dm @@ -5,16 +5,5 @@ priority = TEST_PRE /datum/unit_test/maptest_log_mapping/Run() - var/static/regex/test_areacoord_regex = regex(@"\(-?\d+,-?\d+,(-?\d+)\)") - for(var/log_entry in GLOB.unit_test_mapping_logs) - // Only fail if AREACOORD was conveyed, and it's a station or mining z-level. - // This is due to mapping errors don't have coords being impossible to diagnose as a unit test, - // and various ruins frequently intentionally doing non-standard things. - if(!test_areacoord_regex.Find(log_entry)) - continue - var/z = text2num(test_areacoord_regex.group[1]) - if(!is_station_level(z) && !is_mining_level(z)) - continue - TEST_FAIL(log_entry)