mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 12:08:55 +01:00
Speed up Mapper testing with a prefix "maptest_" in VSCode (#93238)
## About The Pull Request One of the development hell cycles with mapping is how long it takes to fix quality or run issues with maps. By adding a prefix called "maptest_" to some of the unit tests it allows mappers to only target some tests instead of the usual 350+ tests to run each time or trying to trigger them individually and faffing. This does not rename the unit test files themselves to preserve history but just the "/datum/unit_test/" in each file. This does not break the current CI or obstruct other tests - A few other map files that call these tests specifically have been edited to point at the new datum name. This assumes you are using the TG testing extension to do this. | All Tests | maptest_ | |--------|--------| | <img width="426" height="106" alt="image" src="https://github.com/user-attachments/assets/d1d6f81e-16bd-473a-88da-e8b56f8bd3d0" /> | <img width="434" height="96" alt="image" src="https://github.com/user-attachments/assets/ea1c47fe-a6ce-40c6-b2cb-65b9c8e94a29" /> | | <img width="360" height="886" alt="image" src="https://github.com/user-attachments/assets/65bcd774-79ad-432e-8211-c67fb9d3e443" /> | <img width="370" height="833" alt="Screenshot 2025-10-01 204609" src="https://github.com/user-attachments/assets/ad360796-5698-42fd-bd2e-51de1a02ab87" /> | ## Why It's Good For The Game - Should make it easier for mappers to test locally, saving CI/Github resource for TG - Mappers can now test their work 56% faster ## Changelog 🆑 code: Mappers can now run just mapping unit tests - Should be 56% faster - Should have no player impact /🆑 Co-authored-by: loganuk <falseemail@aol.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/// Verifies that an area's perception of their "turfs" is correct, and no other area overlaps with them
|
||||
/// Quite slow, but needed
|
||||
/datum/unit_test/area_contents
|
||||
/datum/unit_test/maptest_area_contents
|
||||
priority = TEST_LONGER
|
||||
|
||||
/datum/unit_test/area_contents/Run()
|
||||
/datum/unit_test/maptest_area_contents/Run()
|
||||
// First, we check that there are no entries in more then one area
|
||||
// That or duplicate entries
|
||||
for (var/area/area_to_test in GLOB.areas)
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
turf.assemble_baseturfs(initial(turf.baseturfs))
|
||||
|
||||
/// Validates that unmodified baseturfs tear down properly
|
||||
/datum/unit_test/baseturfs_unmodified_scrape
|
||||
/datum/unit_test/maptest_baseturfs_unmodified_scrape
|
||||
|
||||
/datum/unit_test/baseturfs_unmodified_scrape/Run()
|
||||
/datum/unit_test/maptest_baseturfs_unmodified_scrape/Run()
|
||||
// What this is specifically doesn't matter, just as long as the test is built for it
|
||||
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, EXPECTED_FLOOR_TYPE, "run_loc_floor_bottom_left should be an iron floor")
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
run_loc_floor_bottom_left.ScrapeAway()
|
||||
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/open/space, "Space should scrape away to space")
|
||||
|
||||
/datum/unit_test/baseturfs_unmodified_scrape/Destroy()
|
||||
/datum/unit_test/maptest_baseturfs_unmodified_scrape/Destroy()
|
||||
RESET_TO_EXPECTED(run_loc_floor_bottom_left)
|
||||
return ..()
|
||||
|
||||
/// Validates that specially placed baseturfs tear down properly
|
||||
/datum/unit_test/baseturfs_placed_on_top
|
||||
/datum/unit_test/maptest_baseturfs_placed_on_top
|
||||
|
||||
/datum/unit_test/baseturfs_placed_on_top/Run()
|
||||
/datum/unit_test/maptest_baseturfs_placed_on_top/Run()
|
||||
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, EXPECTED_FLOOR_TYPE, "run_loc_floor_bottom_left should be an iron floor")
|
||||
|
||||
// Do this instead of just ChangeTurf to guarantee that baseturfs is completely default on-init behavior
|
||||
@@ -40,14 +40,14 @@
|
||||
run_loc_floor_bottom_left.ScrapeAway()
|
||||
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, EXPECTED_FLOOR_TYPE, "Rock wall should've been scraped off, back into the expected type")
|
||||
|
||||
/datum/unit_test/baseturfs_placed_on_top/Destroy()
|
||||
/datum/unit_test/maptest_baseturfs_placed_on_top/Destroy()
|
||||
RESET_TO_EXPECTED(run_loc_floor_bottom_left)
|
||||
return ..()
|
||||
|
||||
/// Validates that specially placed baseturfs BELOW tear down properly
|
||||
/datum/unit_test/baseturfs_placed_on_bottom
|
||||
/datum/unit_test/maptest_baseturfs_placed_on_bottom
|
||||
|
||||
/datum/unit_test/baseturfs_placed_on_bottom/Run()
|
||||
/datum/unit_test/maptest_baseturfs_placed_on_bottom/Run()
|
||||
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, EXPECTED_FLOOR_TYPE, "run_loc_floor_bottom_left should be an iron floor")
|
||||
|
||||
// Do this instead of just ChangeTurf to guarantee that baseturfs is completely default on-init behavior
|
||||
@@ -68,7 +68,7 @@
|
||||
run_loc_floor_bottom_left.ScrapeAway()
|
||||
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/open/floor/plating, "Rock wall should've scraped down back to plating (because it's a wall)")
|
||||
|
||||
/datum/unit_test/baseturfs_placed_on_bottom/Destroy()
|
||||
/datum/unit_test/maptest_baseturfs_placed_on_bottom/Destroy()
|
||||
RESET_TO_EXPECTED(run_loc_floor_bottom_left)
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
///ensures that get_turf_pixel() returns turfs within the bounds of the map,
|
||||
///even when called on a movable with its sprite out of bounds
|
||||
/datum/unit_test/get_turf_pixel
|
||||
/datum/unit_test/maptest_get_turf_pixel
|
||||
|
||||
/datum/unit_test/get_turf_pixel/Run()
|
||||
/datum/unit_test/maptest_get_turf_pixel/Run()
|
||||
//we need long larry to peek over the top edge of the earth
|
||||
var/turf/north = locate(1, world.maxy, run_loc_floor_bottom_left.z)
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#define VALID_TEST_MAP "runtimestation"
|
||||
|
||||
/// Tests to ensure we can load a map from a whitelisted directory (_maps), but not a non-whitelisted directory (i.e "fartyShitPants")
|
||||
/datum/unit_test/load_map_security
|
||||
/datum/unit_test/maptest_load_map_security
|
||||
|
||||
/datum/unit_test/load_map_security/Run()
|
||||
/datum/unit_test/maptest_load_map_security/Run()
|
||||
|
||||
// Copy our valid map into a bad directory
|
||||
// We can technically load from /unitTestTempDir by passing it in our map name
|
||||
@@ -34,7 +34,7 @@
|
||||
TEST_ASSERT(bad_config.defaulted, "Loaded from non-whitelisted directory: data/load_map_security_temp/[VALID_TEST_MAP]")
|
||||
|
||||
|
||||
/datum/unit_test/load_map_security/Destroy()
|
||||
/datum/unit_test/maptest_load_map_security/Destroy()
|
||||
// Clean up our temp directory
|
||||
fdel("data/load_map_security_temp/")
|
||||
return ..()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// Tests that [/datum/job/proc/get_default_roundstart_spawn_point] returns a landmark from all joinable jobs.
|
||||
/datum/unit_test/job_roundstart_spawnpoints
|
||||
/datum/unit_test/maptest_job_roundstart_spawnpoints
|
||||
|
||||
/datum/unit_test/job_roundstart_spawnpoints/Run()
|
||||
/datum/unit_test/maptest_job_roundstart_spawnpoints/Run()
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
if(job.spawn_positions <= 0)
|
||||
// Zero spawn positions means we don't need to care if they don't have a roundstart landmark
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/// Verifies that there are no space turfs inside a station area, or on any planetary z-level. Sometimes, these are introduced during the load of the map and are not present in the DMM itself.
|
||||
/// Let's just make sure that we have a stop-gap measure in place to catch these if they pop up so we don't put it onto production servers should something errant come up.
|
||||
/datum/unit_test/mapload_space_verification
|
||||
/datum/unit_test/maptest_mapload_space_verification
|
||||
// This test is quite taxing time-wise, so let's run it later than other faster tests.
|
||||
priority = TEST_LONGER
|
||||
|
||||
/datum/unit_test/mapload_space_verification/Run()
|
||||
/datum/unit_test/maptest_mapload_space_verification/Run()
|
||||
// Is our current map a planetary station (NO space turfs allowed)? If so, check for ANY space turfs.
|
||||
if(SSmapping.is_planetary())
|
||||
validate_planetary_map()
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
/// Verifies that there are ZERO space turfs on a valid planetary station. We NEVER want space turfs here, so we do not check for /area/space here since something completely undesirable is happening.
|
||||
/// There are also a few considerations specific to planetary stations included within, so let's spin it out into a separate proc for clarity.
|
||||
/datum/unit_test/mapload_space_verification/proc/validate_planetary_map()
|
||||
/datum/unit_test/maptest_mapload_space_verification/proc/validate_planetary_map()
|
||||
// We want to get both the station level and the mining level (if the two are seperate for any reason).
|
||||
var/list/testable_levels = list()
|
||||
testable_levels += SSmapping.levels_by_trait(ZTRAIT_STATION) // Station z-levels get to be in by default because they can derail an entire round and cause LINDA to weep if a space turf is present.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/// Conveys all log_mapping messages as unit test failures, as they all indicate mapping problems.
|
||||
/datum/unit_test/log_mapping
|
||||
/datum/unit_test/maptest_log_mapping
|
||||
// Happen before all other tests, to make sure we only capture normal mapping logs.
|
||||
priority = TEST_PRE
|
||||
|
||||
/datum/unit_test/log_mapping/Run()
|
||||
/datum/unit_test/maptest_log_mapping/Run()
|
||||
var/static/regex/test_areacoord_regex = regex(@"\(-?\d+,-?\d+,(-?\d+)\)")
|
||||
|
||||
for(var/log_entry in GLOB.unit_test_mapping_logs)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
///Detects movables that may have been accidentally placed in space, as well as movables which do not have the proper nearspace area (meaning they aren't lit properly.)
|
||||
/datum/unit_test/mapping_nearstation_test
|
||||
/datum/unit_test/maptest_mapping_nearstation_test
|
||||
priority = TEST_PRE
|
||||
|
||||
/datum/unit_test/mapping_nearstation_test/Run()
|
||||
/datum/unit_test/maptest_mapping_nearstation_test/Run()
|
||||
if(SSmapping.is_planetary())
|
||||
return //No need to test for orphaned spaced atoms on this map.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/datum/unit_test/modular_map_loader
|
||||
/datum/unit_test/maptest_modular_map_loader
|
||||
|
||||
/datum/unit_test/modular_map_loader/Run()
|
||||
/datum/unit_test/maptest_modular_map_loader/Run()
|
||||
for (var/obj/modular_map_root/map_root_type as anything in subtypesof(/obj/modular_map_root))
|
||||
var/config_file = initial(map_root_type.config_file)
|
||||
if (!fexists(config_file))
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
* - Add the typepath(s) to setup_expected_types
|
||||
* - In the type's initialize, REGISTER_REQUIRED_MAP_ITEM() a minimum and maximum
|
||||
*/
|
||||
/datum/unit_test/required_map_items
|
||||
/datum/unit_test/maptest_required_map_items
|
||||
/// A list of all typepaths that we expect to be in the required items list
|
||||
var/list/expected_types = list()
|
||||
|
||||
/// Used to fill the expected types list with all the types we look for on the map.
|
||||
/// This list will just be full of typepaths that we expect.
|
||||
/// More detailed information about each item (mainly, how much of each should exist) is set on a per item basis
|
||||
/datum/unit_test/required_map_items/proc/setup_expected_types()
|
||||
/datum/unit_test/maptest_required_map_items/proc/setup_expected_types()
|
||||
expected_types += subtypesof(/obj/item/stamp/head)
|
||||
expected_types += subtypesof(/obj/machinery/modular_computer/preset/cargochat)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
expected_types += /obj/machinery/drone_dispenser
|
||||
expected_types += /obj/item/piggy_bank/vault
|
||||
|
||||
/datum/unit_test/required_map_items/Run()
|
||||
/datum/unit_test/maptest_required_map_items/Run()
|
||||
setup_expected_types()
|
||||
|
||||
var/list/required_map_items = GLOB.required_map_items.Copy()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/// Makes sure turf icons actually exist. :)
|
||||
/datum/unit_test/turf_icons
|
||||
/datum/unit_test/maptest_turf_icons
|
||||
var/modular_mineral_turf_file //= 'icons/turf/mining.dmi' //MODULARITY SUPPORT - insert your snowflake MAP_SWITCH icon file here if you use that define.
|
||||
|
||||
/datum/unit_test/turf_icons/Run()
|
||||
/datum/unit_test/maptest_turf_icons/Run()
|
||||
for(var/turf/turf_path as anything in (subtypesof(/turf) - typesof(/turf/closed/mineral)))
|
||||
|
||||
var/icon_state = initial(turf_path.icon_state)
|
||||
|
||||
Reference in New Issue
Block a user