From bee63ff37a3b5eb75b3349de8c2f75af0d7a5652 Mon Sep 17 00:00:00 2001 From: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com> Date: Sat, 28 Nov 2020 02:36:02 -0800 Subject: [PATCH] Fixes incapacitating sleep test failure, general test touch ups. (#55196) Fixes the random incapacitating sleep test failure Tests now provide the option to use a custom turf, by default uses plasteel tiles instead of space Tests now reserve turf instead of just using a corner in CentCom (which had unaccounted for tiles) --- code/game/atoms_movable.dm | 5 ++--- code/modules/mob/living/living.dm | 5 ++--- .../modules/unit_tests/machine_disassembly.dm | 1 - code/modules/unit_tests/reagent_mod_expose.dm | 8 +++++++- code/modules/unit_tests/unit_test.dm | 19 ++++++++++++++++--- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 4f25ded8428..f69c0fadedc 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -907,9 +907,8 @@ if(throwing) return if(on && !(movement_type & FLOATING)) - animate(src, pixel_y = pixel_y + 2, time = 10, loop = -1) - sleep(10) - animate(src, pixel_y = pixel_y - 2, time = 10, loop = -1) + animate(src, pixel_y = 2, time = 10, loop = -1, flags = ANIMATION_RELATIVE) + animate(pixel_y = -2, time = 10, loop = -1, flags = ANIMATION_RELATIVE) setMovetype(movement_type | FLOATING) else if (!on && (movement_type & FLOATING)) animate(src, pixel_y = base_pixel_y, time = 10) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 7cabb1ee860..9164e977210 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -944,9 +944,8 @@ if(anchored || (buckled?.anchored)) fixed = 1 if(on && !(movement_type & FLOATING) && !fixed) - animate(src, pixel_y = pixel_y + 2, time = 10, loop = -1) - sleep(10) - animate(src, pixel_y = pixel_y - 2, time = 10, loop = -1) + animate(src, pixel_y = 2, time = 10, loop = -1, flags = ANIMATION_RELATIVE) + animate(pixel_y = -2, time = 10, loop = -1, flags = ANIMATION_RELATIVE) setMovetype(movement_type | FLOATING) else if(((!on || fixed) && (movement_type & FLOATING))) animate(src, pixel_y = base_pixel_y + body_position_pixel_y_offset, time = 1 SECONDS) diff --git a/code/modules/unit_tests/machine_disassembly.dm b/code/modules/unit_tests/machine_disassembly.dm index bcc769bcf23..e0e38214aa6 100644 --- a/code/modules/unit_tests/machine_disassembly.dm +++ b/code/modules/unit_tests/machine_disassembly.dm @@ -3,7 +3,6 @@ var/obj/machinery/freezer = allocate(/obj/machinery/atmospherics/components/unary/thermomachine/freezer) var/turf/freezer_location = freezer.loc - freezer_location.ChangeTurf(/turf/open/floor/plasteel) freezer.deconstruct() // Check that the components are created diff --git a/code/modules/unit_tests/reagent_mod_expose.dm b/code/modules/unit_tests/reagent_mod_expose.dm index 04ff5543bc7..7f1c265f6f5 100644 --- a/code/modules/unit_tests/reagent_mod_expose.dm +++ b/code/modules/unit_tests/reagent_mod_expose.dm @@ -11,6 +11,9 @@ target.health = 80 /datum/unit_test/reagent_mob_expose/Run() + // Life() is handled just by tests + SSmobs.pause() + var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human) var/obj/item/reagent_containers/dropper/dropper = allocate(/obj/item/reagent_containers/dropper) var/obj/item/reagent_containers/food/drinks/drink = allocate(/obj/item/reagent_containers/food/drinks/bottle) @@ -23,7 +26,7 @@ drink.attack(human, human) TEST_ASSERT_EQUAL(human.fire_stacks, 1, "Human does not have fire stacks after taking phlogiston") human.Life() - TEST_ASSERT_EQUAL(human.fire_stacks, 2, "Human fire stacks did not increase after life tick") + TEST_ASSERT(human.fire_stacks > 1, "Human fire stacks did not increase after life tick") // TOUCH dropper.reagents.add_reagent(/datum/reagent/water, 1) @@ -50,3 +53,6 @@ syringe.mode = SYRINGE_INJECT syringe.afterattack(human, human, TRUE) TEST_ASSERT_EQUAL(human.health, 80, "Human health did not update after injection from syringe") + +/datum/unit_test/reagent_mob_expose/Destroy() + SSmobs.ignite() diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index 5f5b59cc30c..15fe6b466c2 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -19,20 +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