Unit tests!

This commit is contained in:
AffectedArc07
2021-07-01 22:47:06 +01:00
parent 82e48bb207
commit e1647d0e36
6 changed files with 88 additions and 9 deletions
+1
View File
@@ -3,6 +3,7 @@
#ifdef UNIT_TESTS
#include "component_tests.dm"
#include "config_sanity.dm"
#include "crafting_lists.dm"
#include "log_format.dm"
#include "map_templates.dm"
+61
View File
@@ -0,0 +1,61 @@
// This one test does multiple config things
///datum/unit_test/config_stanity/Run()
/client/verb/test_config_sanity()
// First test the ruins. Space then lava.
var/list/config_space_ruins = GLOB.configuration.ruins.active_space_ruins.Copy() // Copy so we dont remove
var/list/datum/map_template/ruin/space/game_space_ruins = list()
// Yes I know this is inefficient. Sue me.
for(var/path in subtypesof(/datum/map_template/ruin/space))
var/datum/map_template/ruin/space/S = new path()
// istype() doesnt work here. Dont even try it.
if(S.ci_exclude == S.type)
continue
game_space_ruins.Add(S)
for(var/datum/map_template/ruin/space/S in game_space_ruins)
if(S.mappath in config_space_ruins)
// Remove both
game_space_ruins -= S
config_space_ruins -= S.mappath
// Do not confuse this with the map_templates unit test. They do different things!!!!!
if(length(game_space_ruins))
Fail("Space ruins exist in the game code that do not exist in the config file")
for(var/datum/map_template/ruin/space/S in game_space_ruins)
Fail("Ruin [S.type] does not have a valid map path ([S.mappath])")
if(length(config_space_ruins))
Fail("Space ruins exist in the game config that do not have associated datums")
for(var/path in config_space_ruins)
Fail("- [path]")
// Now for lava ruins
var/list/config_lava_ruins = GLOB.configuration.ruins.active_lava_ruins.Copy() // Copy so we dont remove
var/list/datum/map_template/ruin/space/game_lava_ruins = list()
// Yes I know this is inefficient. Sue me.
for(var/path in subtypesof(/datum/map_template/ruin/lavaland))
var/datum/map_template/ruin/lavaland/L = new path()
// istype() doesnt work here. Dont even try it.
if(L.ci_exclude == L.type)
continue
game_lava_ruins.Add(L)
for(var/datum/map_template/ruin/lavaland/L in game_lava_ruins)
if(L.mappath in config_lava_ruins)
// Remove both
game_lava_ruins -= L
config_lava_ruins -= L.mappath
// Do not confuse this with the map_templates unit test. They do different things!!!!!
if(length(game_lava_ruins))
Fail("Lava ruins exist in the game code that do not exist in the config file")
for(var/datum/map_template/ruin/lavaland/L in game_lava_ruins)
Fail("Ruin [L.type] does not have a valid map path ([L.mappath])")
if(length(config_lava_ruins))
Fail("Lava ruins exist in the game config that do not have associated datums")
for(var/path in config_lava_ruins)
Fail("- [path]")
+4
View File
@@ -2,6 +2,10 @@
var/list/datum/map_template/templates = subtypesof(/datum/map_template)
for(var/I in templates)
var/datum/map_template/MT = new I // The new is important here to ensure stuff gets set properly
if(MT.ci_exclude == MT.type)
continue
// Check if it even has a path and if so, does it exist
if(MT.mappath && !fexists(MT.mappath))
Fail("The map file for [MT.type] does not exist!")
if(MT.mappath && !findtext(MT.mappath, ".dmm"))
Fail("The map file for [MT.type] is not a map!")