Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports unit test fix. Shortens CI time significantly. #12078

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ CREATION_TEST_IGNORE_SELF(/turf)
///Can this floor be an underlay, for turf damage
var/can_underlay = TRUE

#if defined(UNIT_TESTS) || defined(SPACEMAN_DMM)
/// For the area_contents list unit test
/// Allows us to know our area without needing to preassign it
/// Sorry for the mess
var/area/in_contents_of
#endif

/turf/vv_edit_var(var_name, new_value)
var/static/list/banned_edits = list("x", "y", "z")
if(var_name in banned_edits)
Expand Down
18 changes: 8 additions & 10 deletions code/modules/unit_tests/area_contents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@
priority = TEST_LONGER

/datum/unit_test/area_contents/Run()
/// assoc list of turfs -> areas
var/list/turf_to_area = list()
// First, we check that there are no entries in more then one area
// That or duplicate entries
for(var/area/space in GLOB.areas)
for(var/turf/position as anything in space.get_contained_turfs())
if(!isturf(position))
TEST_FAIL("Found a [position.type] in [space.type]'s turf listing")

var/area/existing = turf_to_area[position]
if(existing == space)
TEST_FAIL("Found a duplicate turf [position.type] inside [space.type]'s turf listing")
else if(existing)
TEST_FAIL("Found a shared turf [position.type] between [space.type] and [existing.type]'s turf listings")
if(position.in_contents_of)
var/area/existing = position.in_contents_of
if(existing == space)
TEST_FAIL("Found a duplicate turf [position.type] inside [space.type]'s turf listing")
else
TEST_FAIL("Found a shared turf [position.type] between [space.type] and [existing.type]'s turf listings")

var/area/dream_spot = position.loc
if(dream_spot != space)
TEST_FAIL("Found a turf [position.type] which is IN [dream_spot.type], but is registered as being in [space.type]")

turf_to_area[position] = space
position.in_contents_of = space

for(var/turf/position in ALL_TURFS())
if(!turf_to_area[position])
if(!position.in_contents_of)
TEST_FAIL("Found a turf [position.type] inside [position.loc.type] that is NOT stored in any area's turf listing")

Loading