From 99ad70a5c0204d15041eea32230ff15475b0248c Mon Sep 17 00:00:00 2001 From: warriorstar-orion Date: Fri, 31 Jan 2025 18:10:03 -0500 Subject: [PATCH] minor test fixture improvements (#28207) * minor test fixture improvements * make return values sane --- code/tests/_game_test.dm | 2 ++ code/tests/_game_test_puppeteer.dm | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/code/tests/_game_test.dm b/code/tests/_game_test.dm index e94e10d85e65..a7853c1d277b 100644 --- a/code/tests/_game_test.dm +++ b/code/tests/_game_test.dm @@ -17,6 +17,8 @@ GLOBAL_LIST_EMPTY(game_test_chats) #define TEST_ASSERT_LAST_CHATLOG(puppet, text) if(!puppet.last_chatlog_has_text(text)) { return Fail("Expected `[text]` in last chatlog but got `[puppet.get_last_chatlog()]`", __FILE__, __LINE__) } +#define TEST_ASSERT_ANY_CHATLOG(puppet, text) if(!puppet.any_chatlog_has_text(text)) { return Fail("Expected `[text]` in any chatlog but got [jointext(puppet.get_chatlogs(), "\n")]", __FILE__, __LINE__) } + /// Asserts that the two parameters passed are equal, fails otherwise /// Optionally allows an additional message in the case of a failure #define TEST_ASSERT_EQUAL(a, b, message) do { \ diff --git a/code/tests/_game_test_puppeteer.dm b/code/tests/_game_test_puppeteer.dm index 9d56066a4073..525b3c7991dd 100644 --- a/code/tests/_game_test_puppeteer.dm +++ b/code/tests/_game_test_puppeteer.dm @@ -52,9 +52,9 @@ var/datum/test_puppeteer/puppet_target = target if(istype(puppet_target)) puppet.ClickOn(puppet_target.puppet, params) - return + else + puppet.ClickOn(target, params) - puppet.ClickOn(target, params) puppet.next_click = world.time puppet.next_move = world.time @@ -94,14 +94,25 @@ puppet.rejuvenate() /datum/test_puppeteer/proc/get_last_chatlog() - if(!(puppet.mind.key in GLOB.game_test_chats)) - return FALSE - var/list/puppet_chat_list = GLOB.game_test_chats[puppet.mind.key] - return puppet_chat_list[length(puppet_chat_list)] + var/list/puppet_chat_list = get_chatlogs() + if(length(puppet_chat_list)) + return puppet_chat_list[length(puppet_chat_list)] /datum/test_puppeteer/proc/last_chatlog_has_text(snippet) return findtextEx(get_last_chatlog(), snippet) +/datum/test_puppeteer/proc/any_chatlog_has_text(snippet) + for(var/chat_line in get_chatlogs()) + if(findtextEx(chat_line, snippet)) + return TRUE + + return FALSE + +/datum/test_puppeteer/proc/get_chatlogs() + if(!(puppet.mind.key in GLOB.game_test_chats)) + return list() + return GLOB.game_test_chats[puppet.mind.key] + /datum/test_puppeteer/proc/find_nearby(atom_type) for(var/turf/T in RANGE_TURFS(1, puppet)) for(var/atom/A in T.contents)