test_bench 1.2.0.9 → 2.0.0.0.pre1
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/lib/test_bench/cli.rb +268 -18
- data/lib/test_bench/controls/file.rb +5 -0
- data/lib/test_bench/controls/path.rb +1 -11
- data/lib/test_bench/controls/random.rb +7 -0
- data/lib/test_bench/controls/result.rb +1 -1
- data/lib/test_bench/controls/stdin.rb +27 -0
- data/lib/test_bench/controls.rb +7 -24
- data/lib/test_bench/test_bench.rb +23 -77
- data/lib/test_bench.rb +1 -35
- metadata +15 -54
- data/lib/test_bench/cli/parse_arguments.rb +0 -181
- data/lib/test_bench/controls/caller_location.rb +0 -5
- data/lib/test_bench/controls/depth.rb +0 -21
- data/lib/test_bench/controls/device.rb +0 -27
- data/lib/test_bench/controls/directory.rb +0 -15
- data/lib/test_bench/controls/error.rb +0 -35
- data/lib/test_bench/controls/fixture.rb +0 -29
- data/lib/test_bench/controls/output/batch_data.rb +0 -52
- data/lib/test_bench/controls/output/detail_setting.rb +0 -29
- data/lib/test_bench/controls/output/escape_code.rb +0 -23
- data/lib/test_bench/controls/output/exercise.rb +0 -7
- data/lib/test_bench/controls/output/log_level.rb +0 -7
- data/lib/test_bench/controls/output/newline_character.rb +0 -16
- data/lib/test_bench/controls/output/print_error.rb +0 -19
- data/lib/test_bench/controls/output/styling.rb +0 -29
- data/lib/test_bench/controls/output/summary/error.rb +0 -28
- data/lib/test_bench/controls/output/summary/session.rb +0 -20
- data/lib/test_bench/controls/pattern.rb +0 -33
- data/lib/test_bench/controls/test_file.rb +0 -5
- data/lib/test_bench/controls/time.rb +0 -89
- data/lib/test_bench/deactivation_variants.rb +0 -11
- data/lib/test_bench/environment/boolean.rb +0 -40
- data/lib/test_bench/fixtures/configure_receiver.rb +0 -80
- data/lib/test_bench/fixtures.rb +0 -5
- data/lib/test_bench/output/batch_data.rb +0 -17
- data/lib/test_bench/output/buffer.rb +0 -114
- data/lib/test_bench/output/log.rb +0 -27
- data/lib/test_bench/output/print_error.rb +0 -163
- data/lib/test_bench/output/raw.rb +0 -363
- data/lib/test_bench/output/summary/session.rb +0 -94
- data/lib/test_bench/output/summary.rb +0 -146
- data/lib/test_bench/output/timer/substitute.rb +0 -45
- data/lib/test_bench/output/timer.rb +0 -75
- data/lib/test_bench/output/writer/dependency.rb +0 -12
- data/lib/test_bench/output/writer/sgr.rb +0 -54
- data/lib/test_bench/output/writer/substitute.rb +0 -38
- data/lib/test_bench/output/writer.rb +0 -192
- data/lib/test_bench/output.rb +0 -21
- data/lib/test_bench/run/substitute.rb +0 -36
- data/lib/test_bench/run.rb +0 -113
- data/script/bench +0 -19
| @@ -1,363 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Raw
         | 
| 4 | 
            -
                  Error = Class.new(RuntimeError)
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                  include Fixture::Output
         | 
| 7 | 
            -
                  include Writer::Dependency
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                  include PrintError
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                  def verbose
         | 
| 12 | 
            -
                    instance_variable_defined?(:@verbose) ?
         | 
| 13 | 
            -
                      @verbose :
         | 
| 14 | 
            -
                      @verbose = Defaults.verbose
         | 
| 15 | 
            -
                  end
         | 
| 16 | 
            -
                  attr_writer :verbose
         | 
| 17 | 
            -
                  alias_method :verbose?, :verbose
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  def detail_setting
         | 
| 20 | 
            -
                    @detail_setting ||= Defaults.detail
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                  attr_writer :detail_setting
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                  attr_accessor :current_batch
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  def batch_starting(batch_data)
         | 
| 27 | 
            -
                    if batch_data.depth.zero?
         | 
| 28 | 
            -
                      self.current_batch = batch_data
         | 
| 29 | 
            -
                    end
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                  def batch_finished(batch_data)
         | 
| 33 | 
            -
                    if batch_data.depth.zero?
         | 
| 34 | 
            -
                      self.current_batch = nil
         | 
| 35 | 
            -
                    end
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  def previous_byte_offset
         | 
| 39 | 
            -
                    @previous_byte_offset ||= 0
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
                  attr_writer :previous_byte_offset
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                  def configure(verbose: nil, detail: nil, omit_backtrace_pattern: nil, reverse_backtraces: nil, writer: nil, device: nil, styling: nil)
         | 
| 44 | 
            -
                    unless detail.nil?
         | 
| 45 | 
            -
                      self.class.assure_detail_setting(detail)
         | 
| 46 | 
            -
                    end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                    self.detail_setting = detail unless detail.nil?
         | 
| 49 | 
            -
                    self.verbose = verbose unless verbose.nil?
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                    self.omit_backtrace_pattern = omit_backtrace_pattern unless omit_backtrace_pattern.nil?
         | 
| 52 | 
            -
                    self.reverse_backtraces = reverse_backtraces unless reverse_backtraces.nil?
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                    Writer.configure(self, writer: writer, styling: styling, device: device)
         | 
| 55 | 
            -
                  end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  def self.build(verbose: nil, detail: nil, omit_backtrace_pattern: nil, reverse_backtraces: nil, writer: nil, device: nil, styling: nil)
         | 
| 58 | 
            -
                    instance = new
         | 
| 59 | 
            -
                    instance.configure(verbose: verbose, detail: detail, omit_backtrace_pattern: omit_backtrace_pattern, reverse_backtraces: reverse_backtraces, writer: writer, device: device, styling: styling)
         | 
| 60 | 
            -
                    instance
         | 
| 61 | 
            -
                  end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                  def self.configure(receiver, attr_name: nil, **args)
         | 
| 64 | 
            -
                    attr_name ||= :raw_output
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                    instance = build(**args)
         | 
| 67 | 
            -
                    receiver.public_send(:"#{attr_name}=", instance)
         | 
| 68 | 
            -
                    instance
         | 
| 69 | 
            -
                  end
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                  def detail?(result=nil)
         | 
| 72 | 
            -
                    result ||= current_batch&.result
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                    case detail_setting
         | 
| 75 | 
            -
                    when :failure
         | 
| 76 | 
            -
                      result != true
         | 
| 77 | 
            -
                    when :on
         | 
| 78 | 
            -
                      true
         | 
| 79 | 
            -
                    when :off
         | 
| 80 | 
            -
                      false
         | 
| 81 | 
            -
                    end
         | 
| 82 | 
            -
                  end
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                  def enter_context(title, batch_data: nil)
         | 
| 85 | 
            -
                    batch_starting(batch_data) unless batch_data.nil?
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                    return if title.nil?
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                    writer
         | 
| 90 | 
            -
                      .indent
         | 
| 91 | 
            -
                      .escape_code(:green)
         | 
| 92 | 
            -
                      .text(title)
         | 
| 93 | 
            -
                      .escape_code(:reset_fg)
         | 
| 94 | 
            -
                      .newline
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                    writer.increase_indentation
         | 
| 97 | 
            -
                  end
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                  def exit_context(title, result, batch_data: nil)
         | 
| 100 | 
            -
                    return if title.nil?
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                    writer.decrease_indentation
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                    if verbose?
         | 
| 105 | 
            -
                      text = "Finished context #{title.inspect} (Result: #{result_text(result)})"
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                      color = result ? :green : :red
         | 
| 108 | 
            -
             | 
| 109 | 
            -
                      writer
         | 
| 110 | 
            -
                        .indent
         | 
| 111 | 
            -
                        .escape_code(:faint).escape_code(:italic).escape_code(color)
         | 
| 112 | 
            -
                        .text(text)
         | 
| 113 | 
            -
                        .escape_code(:reset_fg).escape_code(:reset_italic).escape_code(:reset_intensity)
         | 
| 114 | 
            -
                        .newline
         | 
| 115 | 
            -
                    end
         | 
| 116 | 
            -
             | 
| 117 | 
            -
                    if writer.indentation_depth.zero?
         | 
| 118 | 
            -
                      writer.newline
         | 
| 119 | 
            -
                    end
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                  ensure
         | 
| 122 | 
            -
                    batch_finished(batch_data) unless batch_data.nil?
         | 
| 123 | 
            -
                  end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
                  def skip_context(title)
         | 
| 126 | 
            -
                    return if title.nil?
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                    writer
         | 
| 129 | 
            -
                      .indent
         | 
| 130 | 
            -
                      .escape_code(:yellow)
         | 
| 131 | 
            -
                      .text(title)
         | 
| 132 | 
            -
                      .escape_code(:reset_fg)
         | 
| 133 | 
            -
                      .newline
         | 
| 134 | 
            -
                  end
         | 
| 135 | 
            -
             | 
| 136 | 
            -
                  def start_test(title, batch_data: nil)
         | 
| 137 | 
            -
                    batch_starting(batch_data) unless batch_data.nil?
         | 
| 138 | 
            -
             | 
| 139 | 
            -
                    batch_data = nil if verbose
         | 
| 140 | 
            -
             | 
| 141 | 
            -
                    if batch_data&.passed? && title.nil?
         | 
| 142 | 
            -
                      return
         | 
| 143 | 
            -
                    end
         | 
| 144 | 
            -
             | 
| 145 | 
            -
                    if batch_data.nil?
         | 
| 146 | 
            -
                      if title.nil?
         | 
| 147 | 
            -
                        text = "Starting test"
         | 
| 148 | 
            -
                      else
         | 
| 149 | 
            -
                        text = "Starting test #{title.inspect}"
         | 
| 150 | 
            -
                      end
         | 
| 151 | 
            -
             | 
| 152 | 
            -
                      writer
         | 
| 153 | 
            -
                        .indent
         | 
| 154 | 
            -
                        .escape_code(:faint)
         | 
| 155 | 
            -
                        .escape_code(:italic)
         | 
| 156 | 
            -
                        .escape_code(:blue)
         | 
| 157 | 
            -
                        .text(text)
         | 
| 158 | 
            -
                        .escape_code(:reset_fg)
         | 
| 159 | 
            -
                        .escape_code(:reset_italic)
         | 
| 160 | 
            -
                        .escape_code(:reset_intensity)
         | 
| 161 | 
            -
                        .newline
         | 
| 162 | 
            -
             | 
| 163 | 
            -
                    else
         | 
| 164 | 
            -
                      result = batch_data.result
         | 
| 165 | 
            -
             | 
| 166 | 
            -
                      print_test_result(title, result)
         | 
| 167 | 
            -
                    end
         | 
| 168 | 
            -
             | 
| 169 | 
            -
                    writer.increase_indentation
         | 
| 170 | 
            -
                  end
         | 
| 171 | 
            -
             | 
| 172 | 
            -
                  def finish_test(title, result, batch_data: nil)
         | 
| 173 | 
            -
                    batch_data = nil if verbose?
         | 
| 174 | 
            -
             | 
| 175 | 
            -
                    if batch_data&.passed? && title.nil?
         | 
| 176 | 
            -
                      return
         | 
| 177 | 
            -
                    end
         | 
| 178 | 
            -
             | 
| 179 | 
            -
                    writer.decrease_indentation
         | 
| 180 | 
            -
             | 
| 181 | 
            -
                    if batch_data.nil?
         | 
| 182 | 
            -
                      print_test_result(title, result)
         | 
| 183 | 
            -
                    end
         | 
| 184 | 
            -
             | 
| 185 | 
            -
                  ensure
         | 
| 186 | 
            -
                    batch_finished(batch_data) unless batch_data.nil?
         | 
| 187 | 
            -
                  end
         | 
| 188 | 
            -
             | 
| 189 | 
            -
                  def print_test_result(title, result)
         | 
| 190 | 
            -
                    title ||= default_test_title
         | 
| 191 | 
            -
             | 
| 192 | 
            -
                    if writer.styling?
         | 
| 193 | 
            -
                      text = title
         | 
| 194 | 
            -
                    elsif result
         | 
| 195 | 
            -
                      text = title
         | 
| 196 | 
            -
                    else
         | 
| 197 | 
            -
                      text = "#{title} (failed)"
         | 
| 198 | 
            -
                    end
         | 
| 199 | 
            -
             | 
| 200 | 
            -
                    color = result ? :green : :red
         | 
| 201 | 
            -
             | 
| 202 | 
            -
                    writer.indent
         | 
| 203 | 
            -
             | 
| 204 | 
            -
                    if result
         | 
| 205 | 
            -
                      writer.escape_code(:green)
         | 
| 206 | 
            -
                    else
         | 
| 207 | 
            -
                      writer.escape_code(:bold).escape_code(:red)
         | 
| 208 | 
            -
                    end
         | 
| 209 | 
            -
             | 
| 210 | 
            -
                    writer.text(text)
         | 
| 211 | 
            -
             | 
| 212 | 
            -
                    writer.escape_code(:reset_fg)
         | 
| 213 | 
            -
                    unless result
         | 
| 214 | 
            -
                      writer.escape_code(:reset_intensity)
         | 
| 215 | 
            -
                    end
         | 
| 216 | 
            -
             | 
| 217 | 
            -
                    writer.newline
         | 
| 218 | 
            -
                  end
         | 
| 219 | 
            -
             | 
| 220 | 
            -
                  def skip_test(title)
         | 
| 221 | 
            -
                    title ||= default_test_title
         | 
| 222 | 
            -
             | 
| 223 | 
            -
                    if writer.styling?
         | 
| 224 | 
            -
                      text = title
         | 
| 225 | 
            -
                    else
         | 
| 226 | 
            -
                      text = "#{title} (skipped)"
         | 
| 227 | 
            -
                    end
         | 
| 228 | 
            -
             | 
| 229 | 
            -
                    writer
         | 
| 230 | 
            -
                      .indent
         | 
| 231 | 
            -
                      .escape_code(:yellow)
         | 
| 232 | 
            -
                      .text(text)
         | 
| 233 | 
            -
                      .escape_code(:reset_fg)
         | 
| 234 | 
            -
                      .newline
         | 
| 235 | 
            -
                  end
         | 
| 236 | 
            -
             | 
| 237 | 
            -
                  def start_fixture(fixture, batch_data: nil)
         | 
| 238 | 
            -
                    batch_starting(batch_data) unless batch_data.nil?
         | 
| 239 | 
            -
             | 
| 240 | 
            -
                    return unless verbose?
         | 
| 241 | 
            -
             | 
| 242 | 
            -
                    fixture_class = fixture.class.inspect
         | 
| 243 | 
            -
             | 
| 244 | 
            -
                    text = "Starting fixture (Fixture: #{fixture_class})"
         | 
| 245 | 
            -
             | 
| 246 | 
            -
                    writer
         | 
| 247 | 
            -
                      .indent
         | 
| 248 | 
            -
                      .escape_code(:blue)
         | 
| 249 | 
            -
                      .text(text)
         | 
| 250 | 
            -
                      .escape_code(:reset_fg)
         | 
| 251 | 
            -
                      .newline
         | 
| 252 | 
            -
             | 
| 253 | 
            -
                    writer.increase_indentation
         | 
| 254 | 
            -
                  end
         | 
| 255 | 
            -
             | 
| 256 | 
            -
                  def finish_fixture(fixture, result, batch_data: nil)
         | 
| 257 | 
            -
                    return unless verbose?
         | 
| 258 | 
            -
             | 
| 259 | 
            -
                    fixture_class = fixture.class.inspect
         | 
| 260 | 
            -
             | 
| 261 | 
            -
                    text = "Finished fixture (Fixture: #{fixture_class}, Result: #{result_text(result)})"
         | 
| 262 | 
            -
             | 
| 263 | 
            -
                    writer.decrease_indentation
         | 
| 264 | 
            -
             | 
| 265 | 
            -
                    writer
         | 
| 266 | 
            -
                      .indent
         | 
| 267 | 
            -
                      .escape_code(:magenta)
         | 
| 268 | 
            -
                      .text(text)
         | 
| 269 | 
            -
                      .escape_code(:reset_fg)
         | 
| 270 | 
            -
                      .newline
         | 
| 271 | 
            -
             | 
| 272 | 
            -
                  ensure
         | 
| 273 | 
            -
                    batch_finished(batch_data) unless batch_data.nil?
         | 
| 274 | 
            -
                  end
         | 
| 275 | 
            -
             | 
| 276 | 
            -
                  def error(error)
         | 
| 277 | 
            -
                    print_error(error)
         | 
| 278 | 
            -
                  end
         | 
| 279 | 
            -
             | 
| 280 | 
            -
                  def comment(text)
         | 
| 281 | 
            -
                    writer
         | 
| 282 | 
            -
                      .indent
         | 
| 283 | 
            -
                      .text(text)
         | 
| 284 | 
            -
                      .newline
         | 
| 285 | 
            -
                  end
         | 
| 286 | 
            -
             | 
| 287 | 
            -
                  def detail(text)
         | 
| 288 | 
            -
                    return unless verbose? || detail?
         | 
| 289 | 
            -
             | 
| 290 | 
            -
                    if verbose? && !detail?
         | 
| 291 | 
            -
                      text = "(detail omitted: #{text})"
         | 
| 292 | 
            -
                    end
         | 
| 293 | 
            -
             | 
| 294 | 
            -
                    writer
         | 
| 295 | 
            -
                      .indent
         | 
| 296 | 
            -
                      .text(text)
         | 
| 297 | 
            -
                      .newline
         | 
| 298 | 
            -
                  end
         | 
| 299 | 
            -
             | 
| 300 | 
            -
                  def enter_file(path)
         | 
| 301 | 
            -
                    text = "Running #{path}"
         | 
| 302 | 
            -
             | 
| 303 | 
            -
                    writer.text(text).newline
         | 
| 304 | 
            -
             | 
| 305 | 
            -
                    self.previous_byte_offset = writer.byte_offset
         | 
| 306 | 
            -
                  end
         | 
| 307 | 
            -
             | 
| 308 | 
            -
                  def exit_file(path, result)
         | 
| 309 | 
            -
                    unless writer.byte_offset > previous_byte_offset
         | 
| 310 | 
            -
                      writer
         | 
| 311 | 
            -
                        .escape_code(:faint)
         | 
| 312 | 
            -
                        .text("(Nothing written)")
         | 
| 313 | 
            -
                        .escape_code(:reset_intensity)
         | 
| 314 | 
            -
                        .newline
         | 
| 315 | 
            -
             | 
| 316 | 
            -
                      writer.newline
         | 
| 317 | 
            -
                    end
         | 
| 318 | 
            -
                  end
         | 
| 319 | 
            -
             | 
| 320 | 
            -
                  def result_text(result)
         | 
| 321 | 
            -
                    result ? 'pass' : 'failure'
         | 
| 322 | 
            -
                  end
         | 
| 323 | 
            -
             | 
| 324 | 
            -
                  def default_test_title
         | 
| 325 | 
            -
                    'Test'
         | 
| 326 | 
            -
                  end
         | 
| 327 | 
            -
             | 
| 328 | 
            -
                  def self.assure_detail_setting(detail_setting)
         | 
| 329 | 
            -
                    unless detail_settings.include?(detail_setting)
         | 
| 330 | 
            -
                      raise Error, "Invalid detail setting #{detail_setting.inspect} (Valid values: #{detail_settings.map(&:inspect).join(', ')})"
         | 
| 331 | 
            -
                    end
         | 
| 332 | 
            -
                  end
         | 
| 333 | 
            -
             | 
| 334 | 
            -
                  def self.detail_settings
         | 
| 335 | 
            -
                    [
         | 
| 336 | 
            -
                      :failure,
         | 
| 337 | 
            -
                      :on,
         | 
| 338 | 
            -
                      :off
         | 
| 339 | 
            -
                    ]
         | 
| 340 | 
            -
                  end
         | 
| 341 | 
            -
             | 
| 342 | 
            -
                  def self.default_detail_setting
         | 
| 343 | 
            -
                    detail_settings.fetch(0)
         | 
| 344 | 
            -
                  end
         | 
| 345 | 
            -
             | 
| 346 | 
            -
                  module Defaults
         | 
| 347 | 
            -
                    def self.verbose
         | 
| 348 | 
            -
                      Environment::Boolean.fetch('TEST_BENCH_VERBOSE', false)
         | 
| 349 | 
            -
                    end
         | 
| 350 | 
            -
             | 
| 351 | 
            -
                    def self.detail
         | 
| 352 | 
            -
                      detail = ::ENV['TEST_BENCH_DETAIL']
         | 
| 353 | 
            -
             | 
| 354 | 
            -
                      if detail.nil?
         | 
| 355 | 
            -
                        Raw.default_detail_setting
         | 
| 356 | 
            -
                      else
         | 
| 357 | 
            -
                        detail.to_sym
         | 
| 358 | 
            -
                      end
         | 
| 359 | 
            -
                    end
         | 
| 360 | 
            -
                  end
         | 
| 361 | 
            -
                end
         | 
| 362 | 
            -
              end
         | 
| 363 | 
            -
            end
         | 
| @@ -1,94 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Summary
         | 
| 4 | 
            -
                  module Session
         | 
| 5 | 
            -
                    def self.call(file_count: nil, test_count: nil, pass_count: nil, skip_count: nil, failure_count: nil, error_count: nil, elapsed_time: nil, writer: nil)
         | 
| 6 | 
            -
                      file_count ||= 0
         | 
| 7 | 
            -
                      test_count ||= 0
         | 
| 8 | 
            -
                      pass_count ||= 0
         | 
| 9 | 
            -
                      skip_count ||= 0
         | 
| 10 | 
            -
                      failure_count ||= 0
         | 
| 11 | 
            -
                      error_count ||= 0
         | 
| 12 | 
            -
                      elapsed_time ||= 0
         | 
| 13 | 
            -
                      writer ||= Writer.build
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                      failed = error_count > 0
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                      if elapsed_time.nonzero?
         | 
| 18 | 
            -
                        tests_per_second = test_count / elapsed_time
         | 
| 19 | 
            -
                      end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                      if failed
         | 
| 22 | 
            -
                        writer.escape_code(:red)
         | 
| 23 | 
            -
                      end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                      writer
         | 
| 26 | 
            -
                        .text("Finished running #{numeric_label(file_count, 'file')}")
         | 
| 27 | 
            -
                        .newline
         | 
| 28 | 
            -
                        .text("Ran %s in %.3fs (%.1f tests/second)" % [
         | 
| 29 | 
            -
                          numeric_label(test_count, 'test'),
         | 
| 30 | 
            -
                          elapsed_time,
         | 
| 31 | 
            -
                          tests_per_second || 0])
         | 
| 32 | 
            -
                        .newline
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                      if pass_count.nonzero? && !failed
         | 
| 35 | 
            -
                        writer
         | 
| 36 | 
            -
                          .escape_code(:green)
         | 
| 37 | 
            -
                          .text("#{pass_count} passed")
         | 
| 38 | 
            -
                          .escape_code(:reset_fg)
         | 
| 39 | 
            -
                      else
         | 
| 40 | 
            -
                        writer.text("#{pass_count} passed")
         | 
| 41 | 
            -
                      end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                      writer.text(", ")
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                      if skip_count.nonzero? && !failed
         | 
| 46 | 
            -
                        writer
         | 
| 47 | 
            -
                          .escape_code(:yellow)
         | 
| 48 | 
            -
                          .text("#{skip_count} skipped")
         | 
| 49 | 
            -
                          .escape_code(:reset_fg)
         | 
| 50 | 
            -
                      else
         | 
| 51 | 
            -
                        writer.text("#{skip_count} skipped")
         | 
| 52 | 
            -
                      end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                      writer.text(", ")
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                      if failure_count.nonzero?
         | 
| 57 | 
            -
                        writer
         | 
| 58 | 
            -
                          .escape_code(:bold)
         | 
| 59 | 
            -
                          .text("#{failure_count} failed")
         | 
| 60 | 
            -
                          .escape_code(:reset_intensity)
         | 
| 61 | 
            -
                      else
         | 
| 62 | 
            -
                        writer.text("0 failed")
         | 
| 63 | 
            -
                      end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                      writer.text(", ")
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                      if failed
         | 
| 68 | 
            -
                        writer
         | 
| 69 | 
            -
                          .escape_code(:bold)
         | 
| 70 | 
            -
                          .text(numeric_label(error_count, 'total error'))
         | 
| 71 | 
            -
                          .escape_code(:reset_intensity)
         | 
| 72 | 
            -
                          .escape_code(:reset_fg)
         | 
| 73 | 
            -
                      else
         | 
| 74 | 
            -
                        writer.text("0 total errors")
         | 
| 75 | 
            -
                      end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                      2.times do
         | 
| 78 | 
            -
                        writer.newline
         | 
| 79 | 
            -
                      end
         | 
| 80 | 
            -
                    end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                    def self.numeric_label(number, label, plural_text=nil)
         | 
| 83 | 
            -
                      plural_text ||= 's'
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                      if number == 1
         | 
| 86 | 
            -
                        "#{number} #{label}"
         | 
| 87 | 
            -
                      else
         | 
| 88 | 
            -
                        "#{number} #{label}#{plural_text}"
         | 
| 89 | 
            -
                      end
         | 
| 90 | 
            -
                    end
         | 
| 91 | 
            -
                  end
         | 
| 92 | 
            -
                end
         | 
| 93 | 
            -
              end
         | 
| 94 | 
            -
            end
         | 
| @@ -1,146 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Summary
         | 
| 4 | 
            -
                  include Fixture::Output
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                  include Writer::Dependency
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  def file_count
         | 
| 9 | 
            -
                    @file_count ||= 0
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
                  attr_writer :file_count
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  def test_count
         | 
| 14 | 
            -
                    @test_count ||= 0
         | 
| 15 | 
            -
                  end
         | 
| 16 | 
            -
                  attr_writer :test_count
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                  def pass_count
         | 
| 19 | 
            -
                    @pass_count ||= 0
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                  attr_writer :pass_count
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                  def skip_count
         | 
| 24 | 
            -
                    @skip_count ||= 0
         | 
| 25 | 
            -
                  end
         | 
| 26 | 
            -
                  attr_writer :skip_count
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                  def failure_count
         | 
| 29 | 
            -
                    @failure_count ||= 0
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
                  attr_writer :failure_count
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  def error_count
         | 
| 34 | 
            -
                    @error_count ||= 0
         | 
| 35 | 
            -
                  end
         | 
| 36 | 
            -
                  attr_writer :error_count
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                  def elapsed_time
         | 
| 39 | 
            -
                    @elapsed_time ||= 0
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
                  attr_writer :elapsed_time
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                  def timer
         | 
| 44 | 
            -
                    @timer ||= Timer::Substitute.build
         | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
                  attr_writer :timer
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                  def errors_by_file
         | 
| 49 | 
            -
                    @errors_by_file ||= Hash.new do |hash, key|
         | 
| 50 | 
            -
                      hash[key] = []
         | 
| 51 | 
            -
                    end
         | 
| 52 | 
            -
                  end
         | 
| 53 | 
            -
                  attr_writer :errors_by_file
         | 
| 54 | 
            -
             | 
| 55 | 
            -
                  attr_accessor :current_file
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  def configure(writer: nil, device: nil, styling: nil)
         | 
| 58 | 
            -
                    Writer.configure(self, writer: writer, device: device, styling: styling)
         | 
| 59 | 
            -
                    Timer.configure(self)
         | 
| 60 | 
            -
                  end
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                  def self.build(writer: nil, device: nil, styling: nil)
         | 
| 63 | 
            -
                    instance = new
         | 
| 64 | 
            -
                    instance.configure(writer: writer, device: device, styling: styling)
         | 
| 65 | 
            -
                    instance
         | 
| 66 | 
            -
                  end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                  def enter_file(file)
         | 
| 69 | 
            -
                    timer.start
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                    self.current_file = file
         | 
| 72 | 
            -
                  end
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                  def exit_file(_, _)
         | 
| 75 | 
            -
                    elapsed_time = timer.stop
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                    self.elapsed_time += elapsed_time
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                    self.file_count += 1
         | 
| 80 | 
            -
                  end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                  def finish_test(_, result)
         | 
| 83 | 
            -
                    self.test_count += 1
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                    if result
         | 
| 86 | 
            -
                      self.pass_count += 1
         | 
| 87 | 
            -
                    else
         | 
| 88 | 
            -
                      self.failure_count += 1
         | 
| 89 | 
            -
                    end
         | 
| 90 | 
            -
                  end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                  def skip_test(_)
         | 
| 93 | 
            -
                    self.skip_count += 1
         | 
| 94 | 
            -
                  end
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                  def error(error)
         | 
| 97 | 
            -
                    errors_by_file[current_file] << error
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                    self.error_count += 1
         | 
| 100 | 
            -
                  end
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                  def finish(_)
         | 
| 103 | 
            -
                    error_summary
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                    session_summary
         | 
| 106 | 
            -
                  end
         | 
| 107 | 
            -
             | 
| 108 | 
            -
                  def session_summary
         | 
| 109 | 
            -
                    Session.(file_count: file_count, test_count: test_count, pass_count: pass_count, skip_count: skip_count, failure_count: failure_count, error_count: error_count, elapsed_time: elapsed_time, writer: writer)
         | 
| 110 | 
            -
                  end
         | 
| 111 | 
            -
             | 
| 112 | 
            -
                  def error_summary
         | 
| 113 | 
            -
                    return if errors_by_file.empty?
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                    writer
         | 
| 116 | 
            -
                      .escape_code(:bold)
         | 
| 117 | 
            -
                      .escape_code(:red)
         | 
| 118 | 
            -
                      .text('Error Summary:')
         | 
| 119 | 
            -
                      .escape_code(:reset_intensity)
         | 
| 120 | 
            -
                      .escape_code(:reset_fg)
         | 
| 121 | 
            -
                      .newline
         | 
| 122 | 
            -
             | 
| 123 | 
            -
                    errors_by_file.each do |file, errors|
         | 
| 124 | 
            -
                      error_count = errors.count
         | 
| 125 | 
            -
             | 
| 126 | 
            -
                      writer
         | 
| 127 | 
            -
                        .text(error_count.to_s.rjust(4, ' '))
         | 
| 128 | 
            -
                        .text(": #{file}")
         | 
| 129 | 
            -
                        .newline
         | 
| 130 | 
            -
             | 
| 131 | 
            -
                      errors.each do |error|
         | 
| 132 | 
            -
                        writer
         | 
| 133 | 
            -
                          .text('      ')
         | 
| 134 | 
            -
                          .escape_code(:red)
         | 
| 135 | 
            -
             | 
| 136 | 
            -
                        PrintError.error_message(error, writer: writer)
         | 
| 137 | 
            -
             | 
| 138 | 
            -
                        writer.escape_code(:reset_fg)
         | 
| 139 | 
            -
                      end
         | 
| 140 | 
            -
                    end
         | 
| 141 | 
            -
             | 
| 142 | 
            -
                    writer.newline
         | 
| 143 | 
            -
                  end
         | 
| 144 | 
            -
                end
         | 
| 145 | 
            -
              end
         | 
| 146 | 
            -
            end
         | 
| @@ -1,45 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Timer
         | 
| 4 | 
            -
                  module Substitute
         | 
| 5 | 
            -
                    def self.build
         | 
| 6 | 
            -
                      Timer.new
         | 
| 7 | 
            -
                    end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                    class Timer < Timer
         | 
| 10 | 
            -
                      def elapsed_time
         | 
| 11 | 
            -
                        @elapsed_time ||= 0.0
         | 
| 12 | 
            -
                      end
         | 
| 13 | 
            -
                      attr_writer :elapsed_time
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                      def mode
         | 
| 16 | 
            -
                        @mode ||= Mode.stopped
         | 
| 17 | 
            -
                      end
         | 
| 18 | 
            -
                      attr_writer :mode
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                      def start(_=nil)
         | 
| 21 | 
            -
                        if mode == Mode.running
         | 
| 22 | 
            -
                          raise Error, "Timer has already started"
         | 
| 23 | 
            -
                        end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                        self.mode = Mode.running
         | 
| 26 | 
            -
                      end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                      def stop(_=nil)
         | 
| 29 | 
            -
                        if mode == Mode.stopped
         | 
| 30 | 
            -
                          raise Error, "Timer has not started"
         | 
| 31 | 
            -
                        end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                        self.mode = Mode.stopped
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                        elapsed_time.round(3)
         | 
| 36 | 
            -
                      end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                      def set(elapsed_time)
         | 
| 39 | 
            -
                        self.elapsed_time = elapsed_time
         | 
| 40 | 
            -
                      end
         | 
| 41 | 
            -
                    end
         | 
| 42 | 
            -
                  end
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
              end
         | 
| 45 | 
            -
            end
         | 
| @@ -1,75 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Timer
         | 
| 4 | 
            -
                  Error = Class.new(RuntimeError)
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                  attr_accessor :start_time
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  def self.configure(receiver, attr_name: nil)
         | 
| 9 | 
            -
                    attr_name ||= :timer
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    instance = new
         | 
| 12 | 
            -
                    receiver.public_send(:"#{attr_name}=", instance)
         | 
| 13 | 
            -
                    instance
         | 
| 14 | 
            -
                  end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                  def start(now=nil)
         | 
| 17 | 
            -
                    now ||= ::Time.now.utc
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                    if mode == Mode.running
         | 
| 20 | 
            -
                      raise Error, "Timer has already started (Start Time: #{start_time})"
         | 
| 21 | 
            -
                    end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                    self.start_time = now
         | 
| 24 | 
            -
                  end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  def stop(now=nil)
         | 
| 27 | 
            -
                    now ||= ::Time.now.utc
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                    if mode == Mode.stopped
         | 
| 30 | 
            -
                      raise Error, "Timer has not started"
         | 
| 31 | 
            -
                    end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                    start_time = reset
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                    elapsed = now - start_time
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                    elapsed.round(3)
         | 
| 38 | 
            -
                  end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                  def running?
         | 
| 41 | 
            -
                    mode == Mode.running
         | 
| 42 | 
            -
                  end
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                  def stopped?
         | 
| 45 | 
            -
                    mode == Mode.stopped
         | 
| 46 | 
            -
                  end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                  def mode
         | 
| 49 | 
            -
                    if start_time.nil?
         | 
| 50 | 
            -
                      Mode.stopped
         | 
| 51 | 
            -
                    else
         | 
| 52 | 
            -
                      Mode.running
         | 
| 53 | 
            -
                    end
         | 
| 54 | 
            -
                  end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                  def reset
         | 
| 57 | 
            -
                    previous_start_time = self.start_time
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                    self.start_time = nil
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                    previous_start_time
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                  module Mode
         | 
| 65 | 
            -
                    def self.running
         | 
| 66 | 
            -
                      :running
         | 
| 67 | 
            -
                    end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                    def self.stopped
         | 
| 70 | 
            -
                      :stopped
         | 
| 71 | 
            -
                    end
         | 
| 72 | 
            -
                  end
         | 
| 73 | 
            -
                end
         | 
| 74 | 
            -
              end
         | 
| 75 | 
            -
            end
         |