mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 18:02:57 +00:00
* maps, tgui, tools * defines and helpers * onclick and controllers * datums fucking caught that hulk reversal too. * game and shuttle modular * module/admin * oh god they fucking moved antag shit again * haaaaate. Haaaaaaaaaate. * enables moff wings * more modules things * tgstation.dme before I forget something important * some mob stuff * s'more mob/living stuff * some carbon stuff * ayy lmaos and kitchen meat * Human stuff * species things moff wings have a 'none' version too * the rest of the module stuff. * some strings * misc * mob icons * some other icons. * It compiles FUCK BORERS FUCK BORERS
78 lines
1.7 KiB
Plaintext
78 lines
1.7 KiB
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
|
|
|
|
*/
|
|
|
|
GLOBAL_DATUM(current_test, /datum/unit_test)
|
|
GLOBAL_VAR_INIT(failed_any_test, FALSE)
|
|
GLOBAL_VAR(test_log)
|
|
|
|
/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)
|
|
|
|
/proc/RunUnitTests()
|
|
CHECK_TICK
|
|
|
|
for(var/I in subtypesof(/datum/unit_test))
|
|
var/datum/unit_test/test = new I
|
|
|
|
GLOB.current_test = test
|
|
var/duration = REALTIMEOFDAY
|
|
|
|
test.Run()
|
|
|
|
duration = REALTIMEOFDAY - duration
|
|
GLOB.current_test = null
|
|
GLOB.failed_any_test |= !test.succeeded
|
|
|
|
var/list/log_entry = list("[test.succeeded ? "PASS" : "FAIL"]: [I] [duration / 10]s")
|
|
var/list/fail_reasons = test.fail_reasons
|
|
|
|
qdel(test)
|
|
|
|
for(var/J in 1 to LAZYLEN(fail_reasons))
|
|
log_entry += "\tREASON #[J]: [fail_reasons[J]]"
|
|
log_test(log_entry.Join("\n"))
|
|
|
|
CHECK_TICK
|
|
|
|
SSticker.force_ending = TRUE
|