@@ -30,10 +30,12 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs)
30
30
var /priority = TEST_DEFAULT
31
31
// internal shit
32
32
var /focus = FALSE
33
- var /succeeded = TRUE
33
+ var /test_status = UNIT_TEST_PASSED
34
34
var /list /allocated
35
35
var /list /fail_reasons
36
36
37
+ var /skip_reason
38
+
37
39
var /static /datum /space_level/reservation
38
40
39
41
/ proc / cmp_unit_test_priority( datum / unit_test/ a, datum / unit_test/ b)
@@ -65,13 +67,18 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs)
65
67
TEST_FAIL (" Run() called parent or not implemented" )
66
68
67
69
/ datum / unit_test/ proc / Fail(reason = " No reason" , file = " OUTDATED_TEST" , line = 1 )
68
- succeeded = FALSE
70
+ test_status = UNIT_TEST_FAILED
69
71
70
72
if (! istext(reason))
71
73
reason = " FORMATTED: [ reason != null ? reason : " NULL" ] "
72
74
73
75
LAZYADD (fail_reasons, list (list (reason, file, line)))
74
76
77
+
78
+ / datum / unit_test/ proc / Skip(reason = " No reason" )
79
+ test_status = UNIT_TEST_SKIPPED
80
+ skip_reason = reason
81
+
75
82
// / Allocates an instance of the provided type, and places it somewhere in an available loc
76
83
// / Instances allocated through this proc will be destroyed when the test is over
77
84
/ datum / unit_test/ proc / allocate(type, ... )
@@ -118,10 +125,21 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs)
118
125
119
126
duration = REALTIMEOFDAY - duration
120
127
GLOB . current_test = null
121
- GLOB . failed_any_test |= ! test. succeeded
128
+ GLOB . failed_any_test |= (test. test_status == UNIT_TEST_FAILED )
129
+
130
+ var /test_log_prefix
131
+ switch (test. test_status)
132
+ if (UNIT_TEST_FAILED )
133
+ test_log_prefix = TEST_OUTPUT_RED (" FAIL" )
134
+ if (UNIT_TEST_PASSED )
135
+ test_log_prefix = TEST_OUTPUT_GREEN (" PASS" )
136
+ if (UNIT_TEST_SKIPPED )
137
+ test_log_prefix = TEST_OUTPUT_BLUE (" SKIPPED" )
138
+ else // what
139
+ test_log_prefix = TEST_OUTPUT_MAGENTA (" BAD STATUS [ test. test_status] " )
122
140
123
141
var /list /log_entry = list (
124
- " [ test . succeeded ? TEST_OUTPUT_GREEN ( " PASS " ) : TEST_OUTPUT_RED ( " FAIL " ) ] : [ test_path] [ duration / 10 ] s" ,
142
+ " [ test_log_prefix ] : [ test_path] [ (test . test_status != UNIT_TEST_SKIPPED ? " [ duration / 10 ] s" : " | [ test . skip_reason ] " ) ] " ,
125
143
)
126
144
var /list /fail_reasons = test. fail_reasons
127
145
var /map_name = SSmapping. config. map_name
@@ -146,7 +164,9 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs)
146
164
var /message = log_entry. Join(" \n " )
147
165
log_test (message)
148
166
149
- test_results[test_path] = list (" status" = test. succeeded ? UNIT_TEST_PASSED : UNIT_TEST_FAILED , " message" = message, " name" = test_path)
167
+
168
+
169
+ test_results[test_path] = list (" status" = test. test_status, " message" = message, " name" = test_path)
150
170
151
171
qdel (test)
152
172
@@ -157,10 +177,15 @@ GLOBAL_LIST_EMPTY(unit_test_mapping_logs)
157
177
158
178
var /list /tests_to_run = subtypesof(/ datum / unit_test)
159
179
var /list /focused_tests = list ()
160
- for (var /_test_to_run in tests_to_run)
161
- var /datum /unit_test/test_to_run = _test_to_run
180
+
181
+ for (var /datum /unit_test/test_to_run as anything in tests_to_run)
182
+ // Handle VSCode Testing Integration Focus Tests
162
183
if (initial(test_to_run. focus))
163
184
focused_tests += test_to_run
185
+ // Remove abstract tests.
186
+ if (isabstract(test_to_run))
187
+ tests_to_run -= test_to_run
188
+
164
189
if (length(focused_tests))
165
190
tests_to_run = focused_tests
166
191
0 commit comments