Files
Bubberstation/code/modules/unit_tests/baseturfs.dm
SimplyLogan 2faa874b3b 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>
2025-10-05 16:25:51 -06:00

77 lines
3.6 KiB
Plaintext

#define EXPECTED_FLOOR_TYPE /turf/open/floor/iron
// Do this instead of just ChangeTurf to guarantee that baseturfs is completely default on-init behavior
#define RESET_TO_EXPECTED(turf) \
turf.ChangeTurf(EXPECTED_FLOOR_TYPE);\
turf.assemble_baseturfs(initial(turf.baseturfs))
/// Validates that unmodified baseturfs tear down properly
/datum/unit_test/maptest_baseturfs_unmodified_scrape
/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")
RESET_TO_EXPECTED(run_loc_floor_bottom_left)
run_loc_floor_bottom_left.ScrapeAway()
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/open/floor/plating, "Iron floors should scrape away to plating")
run_loc_floor_bottom_left.ScrapeAway()
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/open/space, "Plating should scrape away to space")
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/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/maptest_baseturfs_placed_on_top
/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
RESET_TO_EXPECTED(run_loc_floor_bottom_left)
run_loc_floor_bottom_left.place_on_top(/turf/closed/wall/rock)
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/closed/wall/rock, "Rock wall should've been placed on top")
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/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/maptest_baseturfs_placed_on_bottom
/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
RESET_TO_EXPECTED(run_loc_floor_bottom_left)
run_loc_floor_bottom_left.place_on_bottom(/turf/closed/wall/rock)
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, EXPECTED_FLOOR_TYPE, "PlaceOnBottom shouldn't have changed turf")
run_loc_floor_bottom_left.ScrapeAway()
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/open/floor/plating, "Iron floors should scrape away to plating")
run_loc_floor_bottom_left.ScrapeAway()
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/open/space, "Plating should've scraped off to space")
run_loc_floor_bottom_left.ScrapeAway()
TEST_ASSERT_EQUAL(run_loc_floor_bottom_left.type, /turf/closed/wall/rock, "Space should've scraped down to a rock wall")
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/maptest_baseturfs_placed_on_bottom/Destroy()
RESET_TO_EXPECTED(run_loc_floor_bottom_left)
return ..()
#undef RESET_TO_EXPECTED
#undef EXPECTED_FLOOR_TYPE