mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 23:27:34 +01:00
Collect log lines in unit tests (#70362)
* Collect log lines in unit tests
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user