mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-14 03:32:00 +00:00
## 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>
43 lines
1.7 KiB
Plaintext
43 lines
1.7 KiB
Plaintext
// replace runtimestation with another valid _maps .json if not present
|
|
#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/maptest_load_map_security
|
|
|
|
/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
|
|
// But it should fail when passed as a directory
|
|
fcopy("_maps/[VALID_TEST_MAP].json", "data/load_map_security_temp/[VALID_TEST_MAP].json")
|
|
|
|
//Attempt to load our configs
|
|
|
|
// test load from _maps - this should pass
|
|
var/datum/map_config/maps_config = load_map_config(VALID_TEST_MAP, MAP_DIRECTORY_MAPS)
|
|
|
|
// test load from data - this should pass
|
|
// this also confirms that our fcopy worked for our bad_config test
|
|
var/datum/map_config/data_config = load_map_config("load_map_security_temp/[VALID_TEST_MAP]", MAP_DIRECTORY_DATA)
|
|
|
|
// data/load_map_security_temp/ is not in our whitelist, this should fail
|
|
var/datum/map_config/bad_config = load_map_config(VALID_TEST_MAP,"data/load_map_security_temp")
|
|
|
|
|
|
// Check we can load from _maps
|
|
TEST_ASSERT(!maps_config.defaulted, "Failed to load: _maps/[VALID_TEST_MAP]")
|
|
|
|
// Check we can load from data and ensure that our fcopy setup worked
|
|
TEST_ASSERT(!data_config.defaulted, "Failed to load: data/load_map_security_temp/[VALID_TEST_MAP]")
|
|
|
|
// Check we can't load from "bad directory"
|
|
TEST_ASSERT(bad_config.defaulted, "Loaded from non-whitelisted directory: data/load_map_security_temp/[VALID_TEST_MAP]")
|
|
|
|
|
|
/datum/unit_test/maptest_load_map_security/Destroy()
|
|
// Clean up our temp directory
|
|
fdel("data/load_map_security_temp/")
|
|
return ..()
|
|
|
|
#undef VALID_TEST_MAP
|