Collect log lines in unit tests (#70362)

* Collect log lines in unit tests
This commit is contained in:
Mothblocks
2022-10-16 05:47:43 -04:00
committed by GitHub
parent cec4683ad7
commit 00de33c827
+12 -4
View File
@@ -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)