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