mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-19 14:51:27 +00:00
* Implement map tests for catching common errors. - Adds test runner: - to make it easier to track things across test types - for example to ensure a fully specified log can be emitted - Adds map tile test type: - when writing a test, coders implement CheckTile, which is handed a single turf - when the test runner runs these tests, it iterates over all turfs in the specified z-level, and runs each test's CheckTile on each turf in turn. - Adds two sample map tile tests: - check to see if a pipe exists on the same tile as a scrubber or vent - check to see if a tile contains two cables, each with a center node * Review #1: - Replace nested loops over map tiles with `block` - Remove check for valid turf in individual tests, I think it's safe to assume `block` will always return legit turfs - Added proper duration tracking for old tests - Gave log file an appropriate extension - Actually use `Fail` for tests * whoops * add more tests suggested by @Vi3trice * Add some more tests courtesy @Bm0n and @Vi3trice * windows are okay in space as long as it's nearspace * Add failure threshold to prevent excessive logging. Once this threshold is reached, a test will stop being processed for every tile. Note that this applies to `log_world` and `text2file` equally when logging large amounts of failures. * Document each test. * Remove unnecessary reboot * Let all map tests run to completion in CI matrix. * I know what alphabetical means
41 lines
986 B
Plaintext
41 lines
986 B
Plaintext
/*
|
|
Usage:
|
|
Override /Run() to run your test code
|
|
Call Fail() to fail the test (You should specify a reason)
|
|
You may use /New() and /Destroy() for setup/teardown respectively
|
|
You can use the run_loc_bottom_left and run_loc_top_right to get turfs for testing
|
|
*/
|
|
|
|
/datum/unit_test
|
|
//Bit of metadata for the future maybe
|
|
var/list/procs_tested
|
|
|
|
//usable vars
|
|
var/turf/run_loc_bottom_left
|
|
var/turf/run_loc_top_right
|
|
|
|
//internal shit
|
|
var/succeeded = TRUE
|
|
var/list/fail_reasons
|
|
|
|
/datum/unit_test/New()
|
|
run_loc_bottom_left = locate(1, 1, 1)
|
|
run_loc_top_right = locate(5, 5, 1)
|
|
|
|
/datum/unit_test/Destroy()
|
|
//clear the test area
|
|
for(var/atom/movable/AM in block(run_loc_bottom_left, run_loc_top_right))
|
|
qdel(AM)
|
|
return ..()
|
|
|
|
/datum/unit_test/proc/Run()
|
|
Fail("Run() called parent or not implemented")
|
|
|
|
/datum/unit_test/proc/Fail(reason = "No reason")
|
|
succeeded = FALSE
|
|
|
|
if(!istext(reason))
|
|
reason = "FORMATTED: [reason != null ? reason : "NULL"]"
|
|
|
|
LAZYADD(fail_reasons, reason)
|