Common library code for other vc*.nvim projects.

Revamp output format a bit.

+22 -14
+22 -14
lua/vclib/testing.lua
··· 151 151 152 152 local symbol 153 153 local outcome 154 + local name = suite_name 154 155 local timing = string.format("(%.1fms)", duration_ms) 155 - if suite_failed == 0 then 156 - symbol = colorize("✓", PASS) 157 - outcome = string.format("(all %d passed)", suite_total) 156 + local blocks 157 + if suite_total == 0 then 158 + symbol = colorize("-", NOTE) 159 + name = colorize(suite_name, NOTE) 160 + blocks = { symbol, name } 158 161 else 159 - symbol = colorize("✗", FAIL) 160 - outcome = string.format("(%d/%d failed)", suite_failed, suite_total) 162 + if suite_failed == 0 then 163 + symbol = colorize("✓", PASS) 164 + outcome = string.format("(all %d passed)", suite_total) 165 + blocks = { symbol, suite_name, outcome, timing } 166 + else 167 + symbol = colorize("✗", FAIL) 168 + outcome = string.format("(%d/%d failed)", suite_failed, suite_total) 169 + blocks = { symbol, suite_name, outcome, timing } 170 + end 161 171 end 162 - output { symbol, suite_name, outcome, timing } 163 - if suite_skipped > 0 then 164 - output { 165 - " ", 166 - string.format( 167 - colorize("%d tests were skipped due to filtering", NOTE), 168 - suite_skipped 169 - ), 170 - } 172 + if suite_skipped > 0 and suite_total == 0 then 173 + blocks[#blocks + 1] = 174 + colorize(string.format("(all %d skipped)", suite_skipped), NOTE) 175 + else 176 + blocks[#blocks + 1] = 177 + colorize(string.format("(%d skipped)", suite_skipped), NOTE) 171 178 end 179 + output(blocks) 172 180 return suite_failed, suite_total, suite_skipped 173 181 end 174 182