Files
Bubberstation/code/modules/unit_tests/traitor.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

33 lines
1.5 KiB
Plaintext

/datum/unit_test/traitor/Run()
var/datum/dynamic_ruleset/roundstart/traitor/traitor_ruleset = allocate(/datum/dynamic_ruleset/roundstart/traitor)
var/list/possible_jobs = list()
var/list/restricted_roles = traitor_ruleset.restricted_roles
for(var/datum/job/job as anything in SSjob.joinable_occupations)
if(!(job.job_flags & JOB_CREW_MEMBER))
continue
var/rank = job.title
if(rank in restricted_roles)
continue
possible_jobs += rank
for(var/job_name in possible_jobs)
var/datum/job/job = SSjob.GetJob(job_name)
var/mob/living/player = allocate(job.spawn_type)
player.mind_initialize()
var/datum/mind/mind = player.mind
if(ishuman(player))
var/mob/living/carbon/human/human = player
human.equipOutfit(job.outfit)
mind.set_assigned_role(job)
var/datum/antagonist/traitor/traitor = mind.add_antag_datum(/datum/antagonist/traitor)
if(!traitor.uplink_handler)
TEST_FAIL("[job_name] when made traitor does not have a proper uplink created when spawned in!")
for(var/datum/traitor_objective/objective_typepath as anything in subtypesof(/datum/traitor_objective))
if(initial(objective_typepath.abstract_type) == objective_typepath)
continue
var/datum/traitor_objective/objective = allocate(objective_typepath, traitor.uplink_handler)
try
objective.generate_objective(mind, list())
catch(var/exception/exception)
TEST_FAIL("[objective_typepath] failed to generate their objective. Reason: [exception.name] [exception.file]:[exception.line]\n[exception.desc]")