Skip to content

Commit

Permalink
[MIRROR] Give Error Messages On Subsystem Initialization Failure CI (#…
Browse files Browse the repository at this point in the history
…1768) (#2699)

* 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: NovaBot <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
3 people authored Apr 3, 2024
1 parent 461125c commit fd7db0b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions code/controllers/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
/// Previous subsystem in the queue of subsystems to run this tick
var/datum/controller/subsystem/queue_prev

/// String to store an applicable error message for a subsystem crashing, used to help debug crashes in contexts such as Continuous Integration/Unit Tests
var/initialization_failure_message = null

//Do not blindly add vars here to the bottom, put it where it goes above
//If your var only has two values, put it in as a flag.

Expand Down
4 changes: 3 additions & 1 deletion code/controllers/subsystem/lua.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ SUBSYSTEM_DEF(lua)
return SS_INIT_SUCCESS
catch(var/exception/e)
// Something went wrong, best not allow the subsystem to run
warning("Error initializing SSlua: [e.name]")
var/crash_message = "Error initializing SSlua: [e.name]"
initialization_failure_message = crash_message
warning(crash_message)
return SS_INIT_FAILURE

/datum/controller/subsystem/lua/OnConfigLoad()
Expand Down
21 changes: 15 additions & 6 deletions code/modules/unit_tests/subsystem_init.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
for(var/datum/controller/subsystem/subsystem as anything in Master.subsystems)
if(subsystem.flags & SS_NO_INIT)
continue
if(!subsystem.initialized)
var/message = "[subsystem] ([subsystem.type]) is a subsystem meant to initialize but doesn't get set as initialized."
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"))

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (blueshift) / run_integration_tests

Blueshift: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (birdshot) / run_integration_tests

Birdshot Station: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (deltastation) / run_integration_tests

Delta Station: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (gateway_test) / run_integration_tests

Gateway Test: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (kilostation2) / run_integration_tests

Kilo Station: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (icebox) / run_integration_tests

Ice Box Station: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (metastation) / run_integration_tests

MetaStation: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (multiz_debug) / run_integration_tests

MultiZ Debug: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (northstar) / run_integration_tests

NorthStar: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (nssjourney) / run_integration_tests

NSS Journey: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (tramstation) / run_integration_tests

Tramstation: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (runtimestation) / run_integration_tests

Runtime Station: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Integration Tests (voidraptor) / run_integration_tests

Void Raptor: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

Check notice on line 22 in code/modules/unit_tests/subsystem_init.dm

View workflow job for this annotation

GitHub Actions / Alternate Tests (515, 1627, runtimestation) / run_integration_tests

Runtime Station: /datum/unit_test/subsystem_init

Lua Scripting (/datum/controller/subsystem/lua) is a subsystem meant to initialize but could not get initialized. The subsystem reported the following: Error initializing SSlua: FAILED (Couldn't find call_proc_by_id) This subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.

if (subsystem.flags & SS_OK_TO_FAIL_INIT)
TEST_NOTICE(src, "[message]\nThis subsystem is marked as SS_OK_TO_FAIL_INIT. This is still a bug, but it is non-blocking.")
else
TEST_FAIL(message)

0 comments on commit fd7db0b

Please sign in to comment.