Add dotted counts

This commit is contained in:
Nobuyoshi Nakada 2023-08-11 20:17:33 +09:00
parent 2373feade5
commit 2c9fbc5100
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2023-08-12 05:32:41 +00:00

View File

@ -71,7 +71,6 @@ class MSpecScript
prepend JobServer
end
require 'mspec/runner/formatters/dotted'
class DottedFormatter
@ -83,11 +82,12 @@ class DottedFormatter
if out
@columns = nil
else
columns = ENV["COLUMNS"]
@columns = columns ? columns.to_i : 80
columns = ENV["COLUMNS"]&.to_i
@columns = columns&.nonzero? || 80
end
@dotted = 0
@loaded = false
@count = 0
end
def register
@ -97,8 +97,16 @@ class DottedFormatter
end
def after(*)
if @columns
if @dotted == 0
s = sprintf("%6d ", @count)
print(s)
@dotted += s.size
end
@count +=1
end
super
if !@loaded and @columns and (@dotted += 1) >= @columns
if @columns and (@dotted += 1) >= @columns
print "\n"
@dotted = 0
end
@ -106,15 +114,27 @@ class DottedFormatter
def load(*)
file = MSpec.file || MSpec.files_array.first
print "#{file.delete_prefix(BASE)}: "
@loaded = true
s = "#{file.delete_prefix(BASE)}:"
print s
if @columns
if (@dotted += s.size) >= @columns
print "\n"
@dotted = 0
else
print " "
@dotted += 1
end
end
@count = 0
end
def unload
super
if @loaded
print "\n"
print "\n" if @dotted > 0
@dotted = 0
@loaded = nil
end
end
}