mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-30 19:41:56 +00:00
About The Pull Request
Separated compiling the integration tests and running them as separate steps for organization purposes.
Added a TEST_ASSERT_NULL(value, reason) and TEST_ASSERT_NOTNULL(value, reason) because those are conceptually simple tests.
Makes the PASS and FAIL prefixes in the integration test log be green and red for better readability.
Failure reasons now display the file and line number.
In order to achieve this, direct calls to Fail() are now wrapped in a macro, TEST_FAIL(), as Fail() itself needs preprocessor stuff passed to it.
In the midst of updating it, I noticed multiple cases of tests directly calling Fail() and returning when they should have used a better macro, so those were updated. There was at least one case where it appeared that the code assumed that the test ended at Fail(), but made no attempt to do so, such as with the RCD test.
Feel free to double check all of the changed unit tests in case I made a functional behavior change, but they currently pass.
To take advantage of the previous change, failures are now marked as annotations. Note that outside of github, this creates an ugly-looking line but the primary environment is as a github action.
Examples with intentionally botched unit test:
image
image
image
Why It's Good For The Game
Makes inspecting failed unit tests significantly easier.
Changelog
N/A
25 lines
1.4 KiB
Plaintext
25 lines
1.4 KiB
Plaintext
/datum/unit_test/objectives_category/Run()
|
|
var/datum/traitor_category_handler/category_handler = allocate(/datum/traitor_category_handler)
|
|
var/list/objectives_that_exist = list()
|
|
for(var/datum/traitor_objective_category/category as anything in category_handler.all_categories)
|
|
for(var/value in category.objectives)
|
|
TEST_ASSERT(isnum(category.objectives[value]), "[category.type] does not have a valid format for its objectives as an objective category! ([value] requires a weight to be assigned to it)")
|
|
if(islist(value))
|
|
recursive_check_list(category.type, value, objectives_that_exist)
|
|
else
|
|
objectives_that_exist += value
|
|
|
|
for(var/datum/traitor_objective/objective_typepath as anything in subtypesof(/datum/traitor_objective))
|
|
if(initial(objective_typepath.abstract_type) == objective_typepath)
|
|
continue
|
|
if(!(objective_typepath in objectives_that_exist))
|
|
TEST_FAIL("[objective_typepath] is not in a traitor category and isn't an abstract type! Place it into a [/datum/traitor_objective_category] or remove it from code.")
|
|
|
|
/datum/unit_test/objectives_category/proc/recursive_check_list(base_type, list/to_check, list/to_add_to)
|
|
for(var/value in to_check)
|
|
TEST_ASSERT(isnum(to_check[value]), "[base_type] does not have a valid format for its objectives as an objective category! ([value] requires a weight to be assigned to it)")
|
|
if(islist(value))
|
|
recursive_check_list(base_type, value, to_add_to)
|
|
else
|
|
to_add_to += value
|