Files
Bubberstation/code/modules/unit_tests/mob_spawn.dm
Tastyfish bca463316b Makes integration test results be in color and have annotations (#66649)
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
2022-05-04 13:19:01 +12:00

52 lines
2.0 KiB
Plaintext

/// Verifies that all glands for an egg are valid
/datum/unit_test/mob_spawn
/datum/unit_test/mob_spawn/Run()
//these are not expected to be filled out as they are base prototypes
var/list/prototypes = list(
/obj/effect/mob_spawn,
/obj/effect/mob_spawn/corpse,
/obj/effect/mob_spawn/corpse/human,
/obj/effect/mob_spawn/ghost_role,
/obj/effect/mob_spawn/ghost_role/human,
)
//ghost role checks
for(var/role_spawn_path in subtypesof(/obj/effect/mob_spawn/ghost_role) - prototypes)
var/obj/effect/mob_spawn/ghost_role/ghost_role = allocate(role_spawn_path)
if(ghost_role.outfit_override)
TEST_FAIL("[ghost_role.type] has a defined \"outfit_override\" list, which is only for mapping. Do not set this!")
if(ghost_role.mob_type != /mob/living/carbon/human)
//vars that must not be set if the mob type isn't human
var/list/human_only_vars = list(
"mob_species",
"outfit",
"hairstyle",
"facial_hairstyle",
"haircolor",
"facial_haircolor",
"skin_tone",
)
for(var/human_only_var in human_only_vars)
if(ghost_role.vars[human_only_var])
TEST_FAIL("[ghost_role.type] has a defined \"[human_only_var]\" HUMAN ONLY var, but this type doesn't spawn humans.")
//vars that must be set on
var/list/required_vars = list(
//mob_type is not included because the errors on it are loud and some types choose their mob_type on selection
"prompt_name" = "Your ghost role has broken tgui without it.",
//these must be set even if show_flavor is false because the spawn menu still uses them and in 2021 we simply must have higher quality roles
"you_are_text" = "Spawners menu uses it.",
"flavour_text" = "Spawners menu uses it.",
)
for(var/required_var in required_vars)
if(required_var == "prompt_name" && !ghost_role.prompt_ghost)
continue //only case it makes sense why you shouldn't have a prompt_name
if(!ghost_role.vars[required_var])
TEST_FAIL("[ghost_role.type] must have \"[required_var]\" defined. Reason: [required_vars[required_var]]")
qdel(ghost_role)