mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 13:05:36 +01:00
Adds a unit test that all roundstart spawnable jobs have a landmark to spawn at (#74995)
## About The Pull Request https://github.com/tgstation/tgstation/pull/74985#issuecomment-1523773626 Tests that all jobs that have `spawn_position > 0` at roundstart have a location to spawn at. Also changes the failure message for `get_default_roundstart_spawn_point` to send to `log_mapping` rather than `log_world`, as it is a map error and log world doesn't really help anyone. This would've been sufficient for the existing unit test `log_mapping`, but that unit test expects that the log has an areacoord supplied, which we can't really do, given we're reporting a _lack_ of something. ## Why It's Good For The Game Stops maps from regressing and dumping people on the latejoin shuttle roundstart. ## Changelog ~~Not necessary unless I find a map which forgot a landmark~~ 🆑 Melbert fix: Tramstation Robotics and RD now spawn in their departments roundstart fix: Birdboat detective now spawns in their office /🆑
This commit is contained in:
@@ -421,8 +421,7 @@
|
||||
spawn_point.used = TRUE
|
||||
break
|
||||
if(!.)
|
||||
log_world("Couldn't find a round start spawn point for [title]")
|
||||
|
||||
log_mapping("Job [title] ([type]) couldn't find a round start spawn point.")
|
||||
|
||||
/// Finds a valid latejoin spawn point, checking for events and special conditions.
|
||||
/datum/job/proc/get_latejoin_spawn_point()
|
||||
|
||||
@@ -70,7 +70,12 @@
|
||||
#else
|
||||
#define TEST_OUTPUT_GREEN(text) (text)
|
||||
#endif
|
||||
|
||||
/// Change color to yellow on ANSI terminal output, if enabled with -DANSICOLORS.
|
||||
#ifdef ANSICOLORS
|
||||
#define TEST_OUTPUT_YELLOW(text) "\x1B\x5B1;33m[text]\x1B\x5B0m"
|
||||
#else
|
||||
#define TEST_OUTPUT_YELLOW(text) (text)
|
||||
#endif
|
||||
/// A trait source when adding traits through unit tests
|
||||
#define TRAIT_SOURCE_UNIT_TESTS "unit_tests"
|
||||
|
||||
@@ -142,6 +147,7 @@
|
||||
#include "lungs.dm"
|
||||
#include "load_map_security.dm"
|
||||
#include "machine_disassembly.dm"
|
||||
#include "map_landmarks.dm"
|
||||
#include "mapload_space_verification.dm"
|
||||
#include "mapping.dm"
|
||||
#include "mecha_damage.dm"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/// Tests that [/datum/job/proc/get_default_roundstart_spawn_point] returns a landmark from all joinable jobs.
|
||||
/datum/unit_test/job_roundstart_spawnpoints
|
||||
|
||||
/datum/unit_test/job_roundstart_spawnpoints/Run()
|
||||
for(var/datum/job/job as anything in SSjob.joinable_occupations)
|
||||
if(job.spawn_positions <= 0)
|
||||
// Zero spawn positions means we don't need to care if they don't have a roundstart landmark
|
||||
continue
|
||||
if(job.get_default_roundstart_spawn_point())
|
||||
continue
|
||||
|
||||
TEST_FAIL("Job [job.title] ([job.type]) has no default roundstart spawn landmark.")
|
||||
@@ -17,4 +17,3 @@
|
||||
continue
|
||||
|
||||
TEST_FAIL(log_entry)
|
||||
|
||||
|
||||
@@ -159,40 +159,51 @@ GLOBAL_VAR_INIT(focused_tests, focused_tests())
|
||||
|
||||
GLOB.current_test = test
|
||||
var/duration = REALTIMEOFDAY
|
||||
var/skip_test = (test_path in SSmapping.config.skipped_tests)
|
||||
var/test_output_desc = "[test_path]"
|
||||
var/message = ""
|
||||
|
||||
log_world("::group::[test_path]")
|
||||
test.Run()
|
||||
|
||||
duration = REALTIMEOFDAY - duration
|
||||
GLOB.current_test = null
|
||||
GLOB.failed_any_test |= !test.succeeded
|
||||
if(skip_test)
|
||||
log_world("[TEST_OUTPUT_YELLOW("SKIPPED")] Skipped run on map [SSmapping.config.map_name].")
|
||||
|
||||
var/list/log_entry = list()
|
||||
var/list/fail_reasons = test.fail_reasons
|
||||
else
|
||||
|
||||
for(var/reasonID in 1 to LAZYLEN(fail_reasons))
|
||||
var/text = fail_reasons[reasonID][1]
|
||||
var/file = fail_reasons[reasonID][2]
|
||||
var/line = fail_reasons[reasonID][3]
|
||||
test.Run()
|
||||
|
||||
test.log_for_test(text, "error", file, line)
|
||||
duration = REALTIMEOFDAY - duration
|
||||
GLOB.current_test = null
|
||||
GLOB.failed_any_test |= !test.succeeded
|
||||
|
||||
// Normal log message
|
||||
log_entry += "\tFAILURE #[reasonID]: [text] at [file]:[line]"
|
||||
var/list/log_entry = list()
|
||||
var/list/fail_reasons = test.fail_reasons
|
||||
|
||||
var/message = log_entry.Join("\n")
|
||||
log_test(message)
|
||||
for(var/reasonID in 1 to LAZYLEN(fail_reasons))
|
||||
var/text = fail_reasons[reasonID][1]
|
||||
var/file = fail_reasons[reasonID][2]
|
||||
var/line = fail_reasons[reasonID][3]
|
||||
|
||||
var/test_output_desc = "[test_path] [duration / 10]s"
|
||||
if (test.succeeded)
|
||||
log_world("[TEST_OUTPUT_GREEN("PASS")] [test_output_desc]")
|
||||
test.log_for_test(text, "error", file, line)
|
||||
|
||||
// Normal log message
|
||||
log_entry += "\tFAILURE #[reasonID]: [text] at [file]:[line]"
|
||||
|
||||
if(length(log_entry))
|
||||
message = log_entry.Join("\n")
|
||||
log_test(message)
|
||||
|
||||
test_output_desc += " [duration / 10]s"
|
||||
if (test.succeeded)
|
||||
log_world("[TEST_OUTPUT_GREEN("PASS")] [test_output_desc]")
|
||||
|
||||
log_world("::endgroup::")
|
||||
|
||||
if (!test.succeeded)
|
||||
if (!test.succeeded && !skip_test)
|
||||
log_world("::error::[TEST_OUTPUT_RED("FAIL")] [test_output_desc]")
|
||||
|
||||
test_results[test_path] = list("status" = test.succeeded ? UNIT_TEST_PASSED : UNIT_TEST_FAILED, "message" = message, "name" = test_path)
|
||||
var/final_status = skip_test ? UNIT_TEST_SKIPPED : (test.succeeded ? UNIT_TEST_PASSED : UNIT_TEST_FAILED)
|
||||
test_results[test_path] = list("status" = final_status, "message" = message, "name" = test_path)
|
||||
|
||||
qdel(test)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user