code quality
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
/*
|
||||
|
||||
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)
|
||||
@@ -14,19 +19,33 @@ GLOBAL_VAR(test_log)
|
||||
//Bit of metadata for the future maybe
|
||||
var/list/procs_tested
|
||||
|
||||
//usable vars
|
||||
/// The bottom left turf of the testing zone
|
||||
var/turf/run_loc_bottom_left
|
||||
|
||||
/// The top right turf of the testing zone
|
||||
var/turf/run_loc_top_right
|
||||
|
||||
/// The type of turf to allocate for the testing zone
|
||||
var/test_turf_type = /turf/open/floor/plasteel
|
||||
|
||||
//internal shit
|
||||
var/focus = FALSE
|
||||
var/succeeded = TRUE
|
||||
var/list/allocated
|
||||
var/list/fail_reasons
|
||||
|
||||
var/static/datum/turf_reservation/turf_reservation
|
||||
|
||||
/datum/unit_test/New()
|
||||
if (isnull(turf_reservation))
|
||||
turf_reservation = SSmapping.RequestBlockReservation(5, 5)
|
||||
|
||||
for (var/turf/reserved_turf in turf_reservation.reserved_turfs)
|
||||
reserved_turf.ChangeTurf(test_turf_type)
|
||||
|
||||
allocated = new
|
||||
run_loc_bottom_left = locate(1, 1, 1)
|
||||
run_loc_top_right = locate(5, 5, 1)
|
||||
run_loc_bottom_left = locate(turf_reservation.bottom_left_coords[1], turf_reservation.bottom_left_coords[2], turf_reservation.bottom_left_coords[3])
|
||||
run_loc_top_right = locate(turf_reservation.top_right_coords[1], turf_reservation.top_right_coords[2], turf_reservation.top_right_coords[3])
|
||||
|
||||
/datum/unit_test/Destroy()
|
||||
//clear the test area
|
||||
@@ -61,7 +80,14 @@ GLOBAL_VAR(test_log)
|
||||
/proc/RunUnitTests()
|
||||
CHECK_TICK
|
||||
|
||||
for(var/I in subtypesof(/datum/unit_test))
|
||||
var/tests_to_run = subtypesof(/datum/unit_test)
|
||||
for (var/_test_to_run in tests_to_run)
|
||||
var/datum/unit_test/test_to_run = _test_to_run
|
||||
if (initial(test_to_run.focus))
|
||||
tests_to_run = list(test_to_run)
|
||||
break
|
||||
|
||||
for(var/I in tests_to_run)
|
||||
var/datum/unit_test/test = new I
|
||||
|
||||
GLOB.current_test = test
|
||||
|
||||
Reference in New Issue
Block a user