From dfcd16c8ec750eb7f025c907252706fd0fa0674f Mon Sep 17 00:00:00 2001 From: mikomyazaki Date: Thu, 7 Apr 2022 16:00:21 +0100 Subject: [PATCH] Adds ability for unit tests to only run on certain maps. Moves aurora & sccv_horizon tests appropriately. --- code/unit_tests/ss_test.dm | 6 ++++++ code/unit_tests/unit_test.dm | 16 ++++++++-------- code/unit_tests/zas_tests.dm | 16 ---------------- maps/aurora/code/aurora_unittest.dm | 18 ++++++++++++++++++ .../sccv_horizon/code/sccv_horizon_unittest.dm | 8 +++----- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/code/unit_tests/ss_test.dm b/code/unit_tests/ss_test.dm index 02fff571371..8e87d530c6d 100644 --- a/code/unit_tests/ss_test.dm +++ b/code/unit_tests/ss_test.dm @@ -48,6 +48,12 @@ var/datum/unit_test/test = curr[curr.len] curr.len-- + if (test.map_path && current_map && current_map.path != test.map_path) + test.pass("[ascii_red]Check Disabled: This test is not allowed to run on this map.") + if (MC_TICK_CHECK) + return + continue + if (test.disabled) test.pass("[ascii_red]Check Disabled: [test.why_disabled]") if (MC_TICK_CHECK) diff --git a/code/unit_tests/unit_test.dm b/code/unit_tests/unit_test.dm index 17412be038f..a6896a441d9 100644 --- a/code/unit_tests/unit_test.dm +++ b/code/unit_tests/unit_test.dm @@ -41,36 +41,36 @@ var/ascii_reset = "[ascii_esc]\[0m" // We list these here so we can remove them from the for loop running this. // Templates aren't intended to be ran but just serve as a way to create child objects of it with inheritable tests for quick test creation. -datum/unit_test +/datum/unit_test var/name = "template - should not be ran." var/disabled = 0 // If we want to keep a unit test in the codebase but not run it for some reason. var/async = 0 // If the check can be left to do it's own thing, you must define a check_result() proc if you use this. var/reported = 0 // If it's reported a success or failure. Any tests that have not are assumed to be failures. var/why_disabled = "No reason set." // If we disable a unit test we will display why so it reminds us to check back on it later. + var/map_path // This should be the same as the path var on /datum/map - The unit test will only run for that map - -datum/unit_test/proc/fail(var/message) +/datum/unit_test/proc/fail(var/message) all_unit_tests_passed = 0 failed_unit_tests++ reported = 1 log_unit_test("[ascii_red]!!! FAILURE !!! \[[name]\]: [message][ascii_reset]") -datum/unit_test/proc/pass(var/message) +/datum/unit_test/proc/pass(var/message) reported = 1 log_unit_test("[ascii_green]*** SUCCESS *** \[[name]\]: [message][ascii_reset]") -datum/unit_test/proc/warn(var/message) +/datum/unit_test/proc/warn(var/message) log_unit_test("[ascii_yellow]=== WARNING === \[[name]\]: [message][ascii_reset]") -datum/unit_test/proc/start_test() +/datum/unit_test/proc/start_test() fail("No test proc.") -datum/unit_test/proc/check_result() +/datum/unit_test/proc/check_result() fail("No check results proc") return 1 -proc/load_unit_test_changes() +/proc/load_unit_test_changes() /* //This takes about 60 seconds to run on Travis and is only used for the ZAS vacume check on The Asteroid. if(config.generate_asteroid != 1) diff --git a/code/unit_tests/zas_tests.dm b/code/unit_tests/zas_tests.dm index 30eda2c57e3..c0cd4cb206c 100644 --- a/code/unit_tests/zas_tests.dm +++ b/code/unit_tests/zas_tests.dm @@ -109,23 +109,11 @@ datum/unit_test/zas_area_test/supply_centcomm name = "ZAS: Supply Shuttle (CentComm)" area_path = /area/supply/dock -datum/unit_test/zas_area_test/emergency_shuttle - name = "ZAS: Emergency Shuttle" - area_path = /area/shuttle/escape - datum/unit_test/zas_area_test/ai_chamber name = "ZAS: AI Chamber" area_path = /area/turret_protected/ai expectation = UT_NORMAL_COOL -datum/unit_test/zas_area_test/arrival_maint - name = "ZAS: Arrival Maintenance" - area_path = /area/maintenance/arrivals - -datum/unit_test/zas_area_test/ - name = "ZAS: Cargo Maintenance" - area_path = /area/maintenance/cargo - datum/unit_test/zas_area_test/xenobio name = "ZAS: Xenobiology" area_path = /area/rnd/xenobiology @@ -138,10 +126,6 @@ datum/unit_test/zas_area_test/mining_area disabled = 1 why_disabled = "Asteroid Generation disabled" */ -datum/unit_test/zas_area_test/ - name = "ZAS: Cargo Bay" - area_path = /area/quartermaster/storage - // ================================================================================================== diff --git a/maps/aurora/code/aurora_unittest.dm b/maps/aurora/code/aurora_unittest.dm index 77ff6b69558..114cd683551 100644 --- a/maps/aurora/code/aurora_unittest.dm +++ b/maps/aurora/code/aurora_unittest.dm @@ -36,3 +36,21 @@ ,/area/medical/patient_c ,/area/security/penal_colony ) + +/datum/unit_test/zas_area_test/aurora + map_path = "aurora" +/datum/unit_test/zas_area_test/aurora/arrival_maint + name = "ZAS: Arrival Maintenance" + area_path = /area/maintenance/arrivals + +/datum/unit_test/zas_area_test/aurora/emergency_shuttle + name = "ZAS: Emergency Shuttle" + area_path = /area/shuttle/escape + +/datum/unit_test/zas_area_test/aurora/zas_area_test + name = "ZAS: Cargo Bay" + area_path = /area/quartermaster/storage + +/datum/unit_test/zas_area_test/aurora/cargo_maint + name = "ZAS: Cargo Maintenance" + area_path = /area/maintenance/cargo diff --git a/maps/sccv_horizon/code/sccv_horizon_unittest.dm b/maps/sccv_horizon/code/sccv_horizon_unittest.dm index ce205839324..b171f309ec6 100644 --- a/maps/sccv_horizon/code/sccv_horizon_unittest.dm +++ b/maps/sccv_horizon/code/sccv_horizon_unittest.dm @@ -47,10 +47,8 @@ ,/area/rnd/isolation_c ) -/datum/unit_test/zas_area_test +/datum/unit_test/zas_area_test/sccv_horizon + map_path = "sccv_horizon" +/datum/unit_test/zas_area_test/sccv_horizon/storage name = "ZAS: Operations Bay" area_path = /area/operations/storage - -/datum/unit_test/zas_area_test/arrival_maint - name = "ZAS: Arrival Maintenance" - area_path = /area/maintenance/arrivals