-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Genericized atom-counting unit tests (#1172)
* Genericized atom-counting unit test * fuck me * Fix standards failures * This one's experimental. * whoops * Update code/modules/unit_tests/mapping_standards/no_renamed_areas.dm * Update code/modules/unit_tests/mapping_standards/enforce_count/_enforce_count.dm * Killing you, asshole. * If it so pleases the court jester * Area exemption functionality --------- Co-authored-by: Kapu1178 <[email protected]>
- Loading branch information
Showing
8 changed files
with
102 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
code/modules/unit_tests/mapping_standards/enforce_count/_enforce_count.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/datum/unit_test/mapping_standards/enforce_count | ||
abstract_type = /datum/unit_test/mapping_standards/enforce_count | ||
|
||
|
||
var/allowed_count = 1 | ||
|
||
/// Type to check. Includes subtypes. | ||
var/checked_type = null | ||
/// 'Friendly Name' used in fail messages. | ||
var/failed_name = "Bad Objects" | ||
|
||
/datum/unit_test/mapping_standards/enforce_count/proc/get_collection() | ||
TEST_FAIL("Missing Collection Setup, Bad Test!") | ||
|
||
/datum/unit_test/mapping_standards/enforce_count/Run() | ||
if(..()) | ||
return | ||
|
||
/// Turfs we've passed once. We don't fully count every tile. | ||
var/list/turf/checked_turfs = list() | ||
/// Tiles we've fully counted, If we reach these again, we can | ||
/// safely skip them. | ||
var/list/turf/counted_turfs = list() | ||
|
||
for(var/atom/checked_atom as anything in get_collection()) | ||
if(!istype(checked_atom, checked_type)) | ||
continue //Skip types we aren't checking. | ||
var/area/atom_area = get_area(checked_atom) | ||
if(!(atom_area.type in GLOB.the_station_areas)) | ||
continue //Not on station, Skip. | ||
|
||
var/turf/atom_turf = get_turf(checked_atom) | ||
if(atom_turf in checked_turfs) | ||
if(atom_turf in counted_turfs) | ||
continue //Already reported. | ||
counted_turfs.Add(atom_turf) | ||
var/atom_count = 0 | ||
for(var/_counter as anything in atom_turf) | ||
if(!istype(_counter, checked_type)) | ||
continue // Not of the type we care about. | ||
atom_count++ | ||
if(atom_count < allowed_count) | ||
continue //We've counted, but the count came up short. Not a failure. | ||
TEST_FAIL("[atom_count] [failed_name] on tile at [AREACOORD(atom_turf)]") | ||
continue //Already added to the checked list. | ||
//Else | ||
checked_turfs.Add(atom_turf) |
20 changes: 20 additions & 0 deletions
20
code/modules/unit_tests/mapping_standards/enforce_count/doors.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/datum/unit_test/mapping_standards/enforce_count/doors | ||
abstract_type = /datum/unit_test/mapping_standards/enforce_count/doors | ||
|
||
/datum/unit_test/mapping_standards/enforce_count/doors/get_collection() | ||
return INSTANCES_OF(/obj/machinery/door) | ||
|
||
/datum/unit_test/mapping_standards/enforce_count/doors/airlock | ||
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Airlock" | ||
checked_type = /obj/machinery/door/airlock | ||
failed_name = "Airlocks" | ||
|
||
/datum/unit_test/mapping_standards/enforce_count/doors/firedoor | ||
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Firedoor" | ||
checked_type = /obj/machinery/door/firedoor | ||
failed_name = "Firedoors" | ||
|
||
/datum/unit_test/mapping_standards/enforce_count/doors/blastdoor | ||
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Blast Door" | ||
checked_type = /obj/machinery/door/poddoor | ||
failed_name = "Blast Doors" |
8 changes: 8 additions & 0 deletions
8
code/modules/unit_tests/mapping_standards/enforce_count/lights.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/datum/unit_test/mapping_standards/enforce_count/lights | ||
name = "MAPSTANDARDS: Tiles Must Have At Most 1 Light" | ||
|
||
checked_type = /obj/machinery/light | ||
failed_name = "Lights" | ||
|
||
/datum/unit_test/mapping_standards/enforce_count/lights/get_collection() | ||
return INSTANCES_OF(/obj/machinery/light) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
code/modules/unit_tests/mapping_standards/no_renamed_areas.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/datum/unit_test/mapping_standards/no_renamed_areas | ||
name = "MAPSTANDARDS: Areas must not be renamed" | ||
|
||
var/list/area/exempt_areas = list( | ||
//None | ||
) | ||
|
||
/datum/unit_test/mapping_standards/no_renamed_areas/Run() | ||
if(..()) | ||
return | ||
|
||
for(var/area/area in GLOB.areas) | ||
if(!(area.type in exempt_areas) && (area.name != initial(area.name))) | ||
// Unique areas might be worth exempting here? But at the same time, there's no throws here with no check. -Francinum | ||
TEST_FAIL("Area [area]/([initial(area.name)]) at [AREACOORD(area.contents[1])] (Unique: [BOOLEAN(area.area_flags & UNIQUE_AREA)]) has been renamed. ") |
29 changes: 0 additions & 29 deletions
29
code/modules/unit_tests/mapping_standards/one_light_per_tile.dm
This file was deleted.
Oops, something went wrong.