Round down test-spec folding width to a multiple of 20

A prime number 73 is not good for counting.
This commit is contained in:
Nobuyoshi Nakada 2024-05-29 19:49:57 +09:00
parent 4dcd7d6240
commit 632115c11e
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465

View file

@ -90,6 +90,7 @@ require 'mspec/runner/formatters/dotted'
class DottedFormatter class DottedFormatter
prepend Module.new { prepend Module.new {
BASE = __dir__ + "/ruby/" unless defined?(BASE) BASE = __dir__ + "/ruby/" unless defined?(BASE)
COUNT_WIDTH = 6
def initialize(out = nil) def initialize(out = nil)
super super
@ -97,7 +98,10 @@ class DottedFormatter
@columns = nil @columns = nil
else else
columns = ENV["COLUMNS"]&.to_i columns = ENV["COLUMNS"]&.to_i
@columns = columns&.nonzero? || 80 columns = 80 unless columns.nonzero?
w = COUNT_WIDTH + 1
round = 20
@columns = (columns - w) / round * round + w
end end
@dotted = 0 @dotted = 0
@loaded = false @loaded = false
@ -113,7 +117,7 @@ class DottedFormatter
def after(*) def after(*)
if @columns if @columns
if @dotted == 0 if @dotted == 0
s = sprintf("%6d ", @count) s = sprintf("%*d ", COUNT_WIDTH, @count)
print(s) print(s)
@dotted += s.size @dotted += s.size
end end