minitest-reporters 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +1 -0
 - data/lib/minitest/reporters/ansi.rb +1 -0
 - data/lib/minitest/reporters/mean_time_reporter.rb +95 -16
 - data/lib/minitest/reporters/version.rb +1 -1
 - data/test/test_helper.rb +1 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 47b21650aa917c323c0dda549bbf596f3146f390
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 178821e133b2c7472df9a37c800f681078f3c636
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d9014a80d115ad6531f6933c891ae9fc910442ca3a759e7432ff145f72829240ca1fca5f9aac9ebd0b57b52e6a629131ab900f9991faed835f15653e57c82360
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fa0b84409d297219122aea2b5f55496127e250ac28400faffd4a38439fd44cbbc9d8a319f4905cd3ae744e6384b6a70eae3b45292ade68651b9df67ffe639dab
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -45,6 +45,7 @@ Minitest::Reporters::ProgressReporter # => Fuubar-like output with a progress ba 
     | 
|
| 
       45 
45 
     | 
    
         
             
            Minitest::Reporters::RubyMateReporter # => Simple reporter designed for RubyMate
         
     | 
| 
       46 
46 
     | 
    
         
             
            Minitest::Reporters::RubyMineReporter # => Reporter designed for RubyMine IDE and TeamCity CI server
         
     | 
| 
       47 
47 
     | 
    
         
             
            Minitest::Reporters::JUnitReporter    # => JUnit test reporter designed for JetBrains TeamCity
         
     | 
| 
      
 48 
     | 
    
         
            +
            Minitest::Reporters::MeanTimeReporter # => Produces a report summary showing the slowest running tests
         
     | 
| 
       48 
49 
     | 
    
         
             
            ```
         
     | 
| 
       49 
50 
     | 
    
         | 
| 
       50 
51 
     | 
    
         
             
            Options can be passed to these reporters at construction-time, e.g. to force
         
     | 
| 
         @@ -23,6 +23,9 @@ module Minitest 
     | 
|
| 
       23 
23 
     | 
    
         
             
                #
         
     | 
| 
       24 
24 
     | 
    
         
             
                class MeanTimeReporter < Minitest::Reporters::DefaultReporter
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
      
 26 
     | 
    
         
            +
                  class InvalidOrder < StandardError; end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  class InvalidSortColumn < StandardError; end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       26 
29 
     | 
    
         
             
                  # Reset the statistics file for this reporter. Called via a rake task:
         
     | 
| 
       27 
30 
     | 
    
         
             
                  #
         
     | 
| 
       28 
31 
     | 
    
         
             
                  #     rake reset_statistics
         
     | 
| 
         @@ -37,6 +40,13 @@ module Minitest 
     | 
|
| 
       37 
40 
     | 
    
         
             
                  #   by description. Defaults to '/tmp/minitest_reporters_previous_run'.
         
     | 
| 
       38 
41 
     | 
    
         
             
                  # @option report_filename [String] Contains the parsed results for the
         
     | 
| 
       39 
42 
     | 
    
         
             
                  #   last test run. Defaults to '/tmp/minitest_reporters_report'.
         
     | 
| 
      
 43 
     | 
    
         
            +
                  # @option show_count [Fixnum] The number of tests to show in the report
         
     | 
| 
      
 44 
     | 
    
         
            +
                  #   summary at the end of the test run. Default is 15.
         
     | 
| 
      
 45 
     | 
    
         
            +
                  # @option sort_column [Symbol] One of :avg (default), :min, :max, :last.
         
     | 
| 
      
 46 
     | 
    
         
            +
                  #   Determines the column by which the report summary is sorted.
         
     | 
| 
      
 47 
     | 
    
         
            +
                  # @option order [Symbol] One of :desc (default), or :asc. By default the
         
     | 
| 
      
 48 
     | 
    
         
            +
                  #   report summary is listed slowest to fastest (:desc). :asc will order
         
     | 
| 
      
 49 
     | 
    
         
            +
                  #   the report summary as fastest to slowest.
         
     | 
| 
       40 
50 
     | 
    
         
             
                  # @return [Minitest::Reporters::MeanTimeReporter]
         
     | 
| 
       41 
51 
     | 
    
         
             
                  def initialize(options = {})
         
     | 
| 
       42 
52 
     | 
    
         
             
                    super
         
     | 
| 
         @@ -94,7 +104,9 @@ module Minitest 
     | 
|
| 
       94 
104 
     | 
    
         
             
                  #   run.
         
     | 
| 
       95 
105 
     | 
    
         
             
                  def defaults
         
     | 
| 
       96 
106 
     | 
    
         
             
                    {
         
     | 
| 
      
 107 
     | 
    
         
            +
                      order:                  :desc,
         
     | 
| 
       97 
108 
     | 
    
         
             
                      show_count:             15,
         
     | 
| 
      
 109 
     | 
    
         
            +
                      sort_column:            :avg,
         
     | 
| 
       98 
110 
     | 
    
         
             
                      previous_runs_filename: '/tmp/minitest_reporters_previous_run',
         
     | 
| 
       99 
111 
     | 
    
         
             
                      report_filename:        '/tmp/minitest_reporters_report',
         
     | 
| 
       100 
112 
     | 
    
         
             
                    }
         
     | 
| 
         @@ -104,7 +116,9 @@ module Minitest 
     | 
|
| 
       104 
116 
     | 
    
         
             
                  #
         
     | 
| 
       105 
117 
     | 
    
         
             
                  # @return [String]
         
     | 
| 
       106 
118 
     | 
    
         
             
                  def report_title
         
     | 
| 
       107 
     | 
    
         
            -
                    "\n\e[4mMinitest Reporters: Mean Time Report\e[24m  
     | 
| 
      
 119 
     | 
    
         
            +
                    "\n\e[4mMinitest Reporters: Mean Time Report\e[24m " \
         
     | 
| 
      
 120 
     | 
    
         
            +
                    "(Samples: #{samples}, Order: #{sort_column.inspect} " \
         
     | 
| 
      
 121 
     | 
    
         
            +
                    "#{order.inspect})\n"
         
     | 
| 
       108 
122 
     | 
    
         
             
                  end
         
     | 
| 
       109 
123 
     | 
    
         | 
| 
       110 
124 
     | 
    
         
             
                  # The report itself. Displays statistics about all runs, ideal for use
         
     | 
| 
         @@ -113,22 +127,43 @@ module Minitest 
     | 
|
| 
       113 
127 
     | 
    
         
             
                  #
         
     | 
| 
       114 
128 
     | 
    
         
             
                  # @return [String]
         
     | 
| 
       115 
129 
     | 
    
         
             
                  def report_body
         
     | 
| 
      
 130 
     | 
    
         
            +
                    order_sorted_body.each_with_object([]) do |result, obj|
         
     | 
| 
      
 131 
     | 
    
         
            +
                      rating = rate(result[:last], result[:min], result[:max])
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                      obj << "#{avg_label} #{result[:avg]} " \
         
     | 
| 
      
 134 
     | 
    
         
            +
                             "#{min_label} #{result[:min]} " \
         
     | 
| 
      
 135 
     | 
    
         
            +
                             "#{max_label} #{result[:max]} " \
         
     | 
| 
      
 136 
     | 
    
         
            +
                             "#{run_label(rating)} #{result[:last]} " \
         
     | 
| 
      
 137 
     | 
    
         
            +
                             "#{des_label} #{result[:desc]}\n"
         
     | 
| 
      
 138 
     | 
    
         
            +
                    end.join
         
     | 
| 
      
 139 
     | 
    
         
            +
                  end
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                  # @return [String] All of the column-sorted results sorted by the :order
         
     | 
| 
      
 142 
     | 
    
         
            +
                  #   option. (Defaults to :desc).
         
     | 
| 
      
 143 
     | 
    
         
            +
                  def order_sorted_body
         
     | 
| 
      
 144 
     | 
    
         
            +
                    if desc?
         
     | 
| 
      
 145 
     | 
    
         
            +
                      column_sorted_body.reverse
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                    elsif asc?
         
     | 
| 
      
 148 
     | 
    
         
            +
                      column_sorted_body
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                    end
         
     | 
| 
      
 151 
     | 
    
         
            +
                  end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                  # @return [Array<Hash<Symbol => String>>] All of the results sorted by
         
     | 
| 
      
 154 
     | 
    
         
            +
                  #   the :sort_column option. (Defaults to :avg).
         
     | 
| 
      
 155 
     | 
    
         
            +
                  def column_sorted_body
         
     | 
| 
       116 
156 
     | 
    
         
             
                    previous_run.each_with_object([]) do |(description, timings), obj|
         
     | 
| 
       117 
157 
     | 
    
         
             
                      size = Array(timings).size
         
     | 
| 
       118 
158 
     | 
    
         
             
                      sum  = Array(timings).inject { |total, x| total + x }
         
     | 
| 
       119 
     | 
    
         
            -
                       
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                             "#{min_label} #{min} " \
         
     | 
| 
       128 
     | 
    
         
            -
                             "#{max_label} #{max} " \
         
     | 
| 
       129 
     | 
    
         
            -
                             "#{run_label(rating)} #{run} " \
         
     | 
| 
       130 
     | 
    
         
            -
                             "#{des_label} #{description}\n"
         
     | 
| 
       131 
     | 
    
         
            -
                    end.sort.reverse.join
         
     | 
| 
      
 159 
     | 
    
         
            +
                      obj << {
         
     | 
| 
      
 160 
     | 
    
         
            +
                        avg:  (sum / size).round(9).to_s.ljust(12),
         
     | 
| 
      
 161 
     | 
    
         
            +
                        min:  Array(timings).min.round(9).to_s.ljust(12),
         
     | 
| 
      
 162 
     | 
    
         
            +
                        max:  Array(timings).max.round(9).to_s.ljust(12),
         
     | 
| 
      
 163 
     | 
    
         
            +
                        last: Array(timings).last.round(9).to_s.ljust(12),
         
     | 
| 
      
 164 
     | 
    
         
            +
                        desc: description,
         
     | 
| 
      
 165 
     | 
    
         
            +
                      }
         
     | 
| 
      
 166 
     | 
    
         
            +
                    end.sort_by { |k| k[sort_column] }
         
     | 
| 
       132 
167 
     | 
    
         
             
                  end
         
     | 
| 
       133 
168 
     | 
    
         | 
| 
       134 
169 
     | 
    
         
             
                  # @return [Hash]
         
     | 
| 
         @@ -215,9 +250,11 @@ module Minitest 
     | 
|
| 
       215 
250 
     | 
    
         
             
                  end
         
     | 
| 
       216 
251 
     | 
    
         | 
| 
       217 
252 
     | 
    
         
             
                  # Creates a new report file in the 'report_filename'. This file contains
         
     | 
| 
       218 
     | 
    
         
            -
                  # a line for each test of the following example format:
         
     | 
| 
      
 253 
     | 
    
         
            +
                  # a line for each test of the following example format: (this is a single
         
     | 
| 
      
 254 
     | 
    
         
            +
                  # line despite explicit wrapping)
         
     | 
| 
       219 
255 
     | 
    
         
             
                  #
         
     | 
| 
       220 
     | 
    
         
            -
                  # Avg: 0.0555555 Min: 0.0498765 Max: 0.0612345 Last: 0.0499421 
     | 
| 
      
 256 
     | 
    
         
            +
                  # Avg: 0.0555555 Min: 0.0498765 Max: 0.0612345 Last: 0.0499421
         
     | 
| 
      
 257 
     | 
    
         
            +
                  # Description: The test name
         
     | 
| 
       221 
258 
     | 
    
         
             
                  #
         
     | 
| 
       222 
259 
     | 
    
         
             
                  # Note however the timings are to 9 decimal places, and padded to 12
         
     | 
| 
       223 
260 
     | 
    
         
             
                  # characters and each label is coloured, Avg (yellow), Min (green),
         
     | 
| 
         @@ -288,6 +325,48 @@ module Minitest 
     | 
|
| 
       288 
325 
     | 
    
         
             
                    end
         
     | 
| 
       289 
326 
     | 
    
         
             
                  end
         
     | 
| 
       290 
327 
     | 
    
         | 
| 
      
 328 
     | 
    
         
            +
                  # @return [Boolean] Whether the given :order option is :asc.
         
     | 
| 
      
 329 
     | 
    
         
            +
                  def asc?
         
     | 
| 
      
 330 
     | 
    
         
            +
                    order == :asc
         
     | 
| 
      
 331 
     | 
    
         
            +
                  end
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
                  # @return [Boolean] Whether the given :order option is :desc (default).
         
     | 
| 
      
 334 
     | 
    
         
            +
                  def desc?
         
     | 
| 
      
 335 
     | 
    
         
            +
                    order == :desc
         
     | 
| 
      
 336 
     | 
    
         
            +
                  end
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
                  # @raise [Minitest::Reporters::MeanTimeReporter::InvalidOrder]
         
     | 
| 
      
 339 
     | 
    
         
            +
                  #   When the given :order option is invalid.
         
     | 
| 
      
 340 
     | 
    
         
            +
                  # @return [Symbol] The :order option, or by default; :desc.
         
     | 
| 
      
 341 
     | 
    
         
            +
                  def order
         
     | 
| 
      
 342 
     | 
    
         
            +
                    orders = [:desc, :asc]
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
      
 344 
     | 
    
         
            +
                    if orders.include?(options[:order])
         
     | 
| 
      
 345 
     | 
    
         
            +
                      options[:order]
         
     | 
| 
      
 346 
     | 
    
         
            +
             
     | 
| 
      
 347 
     | 
    
         
            +
                    else
         
     | 
| 
      
 348 
     | 
    
         
            +
                      fail Minitest::Reporters::MeanTimeReporter::InvalidOrder,
         
     | 
| 
      
 349 
     | 
    
         
            +
                           "`:order` option must be one of #{orders.inspect}."
         
     | 
| 
      
 350 
     | 
    
         
            +
             
     | 
| 
      
 351 
     | 
    
         
            +
                    end
         
     | 
| 
      
 352 
     | 
    
         
            +
                  end
         
     | 
| 
      
 353 
     | 
    
         
            +
             
     | 
| 
      
 354 
     | 
    
         
            +
                  # @raise [Minitest::Reporters::MeanTimeReporter::InvalidSortColumn]
         
     | 
| 
      
 355 
     | 
    
         
            +
                  #   When the given :sort_column option is invalid.
         
     | 
| 
      
 356 
     | 
    
         
            +
                  # @return [Symbol] The :sort_column option, or by default; :avg.
         
     | 
| 
      
 357 
     | 
    
         
            +
                  def sort_column
         
     | 
| 
      
 358 
     | 
    
         
            +
                    sort_columns = [:avg, :min, :max, :last]
         
     | 
| 
      
 359 
     | 
    
         
            +
             
     | 
| 
      
 360 
     | 
    
         
            +
                    if sort_columns.include?(options[:sort_column])
         
     | 
| 
      
 361 
     | 
    
         
            +
                      options[:sort_column]
         
     | 
| 
      
 362 
     | 
    
         
            +
             
     | 
| 
      
 363 
     | 
    
         
            +
                    else
         
     | 
| 
      
 364 
     | 
    
         
            +
                      fail Minitest::Reporters::MeanTimeReporter::InvalidSortColumn,
         
     | 
| 
      
 365 
     | 
    
         
            +
                           "`:sort_column` option must be one of #{sort_columns.inspect}."
         
     | 
| 
      
 366 
     | 
    
         
            +
             
     | 
| 
      
 367 
     | 
    
         
            +
                    end
         
     | 
| 
      
 368 
     | 
    
         
            +
                  end
         
     | 
| 
      
 369 
     | 
    
         
            +
             
     | 
| 
       291 
370 
     | 
    
         
             
                end
         
     | 
| 
       292 
371 
     | 
    
         
             
              end
         
     | 
| 
       293 
372 
     | 
    
         
             
            end
         
     | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: minitest-reporters
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.1.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Alexander Kern
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-11-26 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: minitest
         
     |