From 00de33c8274442799bf48defca0b90b45dd802e5 Mon Sep 17 00:00:00 2001 From: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Date: Sun, 16 Oct 2022 02:47:43 -0700 Subject: [PATCH] Collect log lines in unit tests (#70362) * Collect log lines in unit tests --- code/modules/unit_tests/unit_test.dm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index f7585804a26..c45f32df66d 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -124,15 +124,14 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs) GLOB.current_test = test var/duration = REALTIMEOFDAY + log_world("::group::[test_path]") test.Run() duration = REALTIMEOFDAY - duration GLOB.current_test = null GLOB.failed_any_test |= !test.succeeded - var/list/log_entry = list( - "[test.succeeded ? TEST_OUTPUT_GREEN("PASS") : TEST_OUTPUT_RED("FAIL")]: [test_path] [duration / 10]s", - ) + var/list/log_entry = list() var/list/fail_reasons = test.fail_reasons for(var/reasonID in 1 to LAZYLEN(fail_reasons)) @@ -143,11 +142,20 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs) test.log_for_test(text, "error", file, line) // Normal log message - log_entry += "\tREASON #[reasonID]: [text] at [file]:[line]" + log_entry += "\tFAILURE #[reasonID]: [text] at [file]:[line]" var/message = log_entry.Join("\n") log_test(message) + var/test_output_desc = "[test_path] [duration / 10]s" + if (test.succeeded) + log_world("[TEST_OUTPUT_GREEN("PASS")] [test_output_desc]") + + log_world("::endgroup::") + + if (!test.succeeded) + 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) qdel(test)