[MIRROR] Added a standardized json unit test results log and added my vscode test runner to recommendations (#2627)

* Added a standardized json unit test results log and added my vscode test runner to recommendations (#56058)

Link to the test explorer: https://marketplace.visualstudio.com/items?itemName=Donkie.vscode-tgstation-test-adapter

The test explorer adapter lets you compile and run the code in one click of a button, with no messing about with defines necessary

The extension supports reading test results from the unit test logs, but its shitty having to parse logs for that, so this PR also adds support for a somewhat standardized method of logging unit test results to a json file instead.

* Added a standardized json unit test results log and added my vscode test runner to recommendations

Co-authored-by: Donkie <daniel.cf.hultgren@gmail.com>
This commit is contained in:
SkyratBot
2021-01-10 23:19:03 +01:00
committed by GitHub
co-authored by Donkie
parent 2ded79c628
commit dace06e524
4 changed files with 21 additions and 5 deletions
+5
View File
@@ -32,6 +32,11 @@
/// Intended to be used in the manner of `TEST_FOCUS(/datum/unit_test/math)`
#define TEST_FOCUS(test_path) ##test_path { focus = TRUE; }
/// Constants indicating unit test completion status
#define UNIT_TEST_PASSED 0
#define UNIT_TEST_FAILED 1
#define UNIT_TEST_SKIPPED 2
#include "anchored_mobs.dm"
#include "bespoke_id.dm"
#include "binary_insert.dm"
+12 -3
View File
@@ -87,6 +87,8 @@ GLOBAL_VAR(test_log)
tests_to_run = list(test_to_run)
break
var/list/test_results = list()
for(var/I in tests_to_run)
var/datum/unit_test/test = new I
@@ -102,12 +104,19 @@ GLOBAL_VAR(test_log)
var/list/log_entry = list("[test.succeeded ? "PASS" : "FAIL"]: [I] [duration / 10]s")
var/list/fail_reasons = test.fail_reasons
qdel(test)
for(var/J in 1 to LAZYLEN(fail_reasons))
log_entry += "\tREASON #[J]: [fail_reasons[J]]"
log_test(log_entry.Join("\n"))
var/message = log_entry.Join("\n")
log_test(message)
test_results[I] = list("status" = test.succeeded ? UNIT_TEST_PASSED : UNIT_TEST_FAILED, "message" = message, "name" = I)
qdel(test)
CHECK_TICK
var/file_name = "data/unit_tests.json"
fdel(file_name)
file(file_name) << json_encode(test_results)
SSticker.force_ending = TRUE