diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-11 20:17:33 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-12 11:19:10 +0900 |
commit | 2c9fbc51005c15600c03b4dc2f545eabd67734b9 (patch) | |
tree | 55ab8b393758dfb0e613f142ee6f7a9174238d21 /spec | |
parent | 2373feade50c5d32dad253ad0651a6a8c7c2a8ac (diff) |
Add dotted counts
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8210
Diffstat (limited to 'spec')
-rw-r--r-- | spec/default.mspec | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/spec/default.mspec b/spec/default.mspec index 4cdd631675..e2ad19e117 100644 --- a/spec/default.mspec +++ b/spec/default.mspec @@ -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 } |