Files
Bubberstation/code/modules/unit_tests/subsystem_init.dm
SkyratBot 5b1881d888 [MIRROR] Give Error Messages On Subsystem Initialization Failure CI (#27144)
* Give Error Messages On Subsystem Initialization Failure CI (#82139)

## About The Pull Request

Noticed during #82138

Basically, the unit test that makes sure that all of the subsystems that
had to initialize properly initialized is good with the Notice
annotation, but it had a flaw - it didn't tell you _why_ the subsystem
failed to initialize:

![image](https://github.com/tgstation/tgstation/assets/34697715/3cd719d2-2f1f-42a9-8c36-d5c37b8a330c)

Basically this PR just adds a variable, `initialization_failure_message`
(i have it on good authority that variables that don't get changed from
their compile time variable don't take up extra memory), and we just
append the failure message to this notice should it occur so all of the
information is available in one spot, rather than have the coder dig
through the CI Run Log to figure out what the specific error was should
it occur on something that isn't SSlua.

also small cute code cleanup :3

* Give Error Messages On Subsystem Initialization Failure CI

---------

Co-authored-by: san7890 <the@san7890.com>
2024-04-04 21:52:32 +02:00

24 lines
906 B
Plaintext

/// Tests that all subsystems that need to properly initialize.
/datum/unit_test/subsystem_init
/datum/unit_test/subsystem_init/Run()
for(var/datum/controller/subsystem/subsystem as anything in Master.subsystems)
if(subsystem.flags & SS_NO_INIT)
continue
if(subsystem.initialized)
continue
var/should_fail = !(subsystem.flags & SS_OK_TO_FAIL_INIT)
var/list/message_strings = list("[subsystem] ([subsystem.type]) is a subsystem meant to initialize but could not get initialized.")
if(!isnull(subsystem.initialization_failure_message))
message_strings += "The subsystem reported the following: [subsystem.initialization_failure_message]"
if(should_fail)
TEST_FAIL(jointext(message_strings, "\n"))
continue
message_strings += "This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking."
TEST_NOTICE(src, jointext(message_strings, "\n"))