Files
Bubberstation/code/modules/unit_tests/designs.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
2.5 KiB
Plaintext

/datum/unit_test/designs
/datum/unit_test/designs/Run()
//Can't use allocate because of bug with certain datums
var/datum/design/default_design = new /datum/design()
var/datum/design/surgery/default_design_surgery = new /datum/design/surgery()
for(var/path in subtypesof(/datum/design))
if (ispath(path, /datum/design/surgery)) //We are checking surgery design separatly later since they work differently
continue
var/datum/design/current_design = new path //Create an instance of each design
if (current_design.id == DESIGN_ID_IGNORE) //Don't check designs with ignore ID
continue
if (isnull(current_design.name) || current_design.name == default_design.name) //Designs with ID must have non default/null Name
TEST_FAIL("Design [current_design.type] has default or null name var but has an ID")
if ((!isnull(current_design.materials) && LAZYLEN(current_design.materials)) || (!isnull(current_design.reagents_list) && LAZYLEN(current_design.reagents_list))) //Design requires materials
if ((isnull(current_design.build_path) || current_design.build_path == default_design.build_path) && (isnull(current_design.make_reagents) || current_design.make_reagents == default_design.make_reagents)) //Check if design gives any output
TEST_FAIL("Design [current_design.type] requires materials but does not have have any build_path or make_reagents set")
else if (!isnull(current_design.build_path) || !isnull(current_design.build_path)) // //Design requires no materials but creates stuff
TEST_FAIL("Design [current_design.type] requires NO materials but has build_path or make_reagents set")
for(var/path in subtypesof(/datum/design/surgery))
var/datum/design/surgery/current_design = new path //Create an instance of each design
if (isnull(current_design.id) || current_design.id == default_design_surgery.id) //Check if ID was not set
TEST_FAIL("Surgery Design [current_design.type] has no ID set")
if (isnull(current_design.id) || current_design.name == default_design_surgery.name) //Check if name was not set
TEST_FAIL("Surgery Design [current_design.type] has default or null name var")
if (isnull(current_design.desc) || current_design.desc == default_design_surgery.desc) //Check if desc was not set
TEST_FAIL("Surgery Design [current_design.type] has default or null desc var")
if (isnull(current_design.surgery) || current_design.surgery == default_design_surgery.surgery) //Check if surgery was not set
TEST_FAIL("Surgery Design [current_design.type] has default or null surgery var")