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,54 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Writer
         | 
| 4 | 
            -
                  module SGR
         | 
| 5 | 
            -
                    def self.escape_code(name)
         | 
| 6 | 
            -
                      assure_escape_code(name)
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                      code_map.fetch(name)
         | 
| 9 | 
            -
                    end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    def self.assure_escape_code(name)
         | 
| 12 | 
            -
                      unless code_map.key?(name)
         | 
| 13 | 
            -
                        raise Error, "Invalid escape code #{name.inspect} (Example values: #{code_map.keys.first(3).map(&:inspect).join(', ')})"
         | 
| 14 | 
            -
                      end
         | 
| 15 | 
            -
                    end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                    def self.code_map
         | 
| 18 | 
            -
                      @code_map ||= {
         | 
| 19 | 
            -
                        :reset => '0',
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                        :bold => '1',
         | 
| 22 | 
            -
                        :faint => '2',
         | 
| 23 | 
            -
                        :italic => '3',
         | 
| 24 | 
            -
                        :underline => '4',
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                        :reset_intensity => '22',
         | 
| 27 | 
            -
                        :reset_italic => '23',
         | 
| 28 | 
            -
                        :reset_underline => '24',
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                        :black => '30',
         | 
| 31 | 
            -
                        :red => '31',
         | 
| 32 | 
            -
                        :green => '32',
         | 
| 33 | 
            -
                        :yellow => '33',
         | 
| 34 | 
            -
                        :blue => '34',
         | 
| 35 | 
            -
                        :magenta => '35',
         | 
| 36 | 
            -
                        :cyan => '36',
         | 
| 37 | 
            -
                        :white => '37',
         | 
| 38 | 
            -
                        :reset_fg => '39',
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                        :black_bg => '40',
         | 
| 41 | 
            -
                        :red_bg => '41',
         | 
| 42 | 
            -
                        :green_bg => '42',
         | 
| 43 | 
            -
                        :yellow_bg => '43',
         | 
| 44 | 
            -
                        :blue_bg => '44',
         | 
| 45 | 
            -
                        :magenta_bg => '45',
         | 
| 46 | 
            -
                        :cyan_bg => '46',
         | 
| 47 | 
            -
                        :white_bg => '47',
         | 
| 48 | 
            -
                        :reset_bg => '49'
         | 
| 49 | 
            -
                      }
         | 
| 50 | 
            -
                    end
         | 
| 51 | 
            -
                  end
         | 
| 52 | 
            -
                end
         | 
| 53 | 
            -
              end
         | 
| 54 | 
            -
            end
         | 
| @@ -1,38 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Writer
         | 
| 4 | 
            -
                  module Substitute
         | 
| 5 | 
            -
                    def self.build
         | 
| 6 | 
            -
                      writer = Writer.new
         | 
| 7 | 
            -
                      writer.styling_enabled = false
         | 
| 8 | 
            -
                      writer
         | 
| 9 | 
            -
                    end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    class Writer < Writer
         | 
| 12 | 
            -
                      def written?(pattern=nil)
         | 
| 13 | 
            -
                        pattern = self.pattern(pattern)
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                        written_text = device.string
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                        pattern.match?(written_text)
         | 
| 18 | 
            -
                      end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                      def pattern(pattern)
         | 
| 21 | 
            -
                        case pattern
         | 
| 22 | 
            -
                        when nil
         | 
| 23 | 
            -
                          /./
         | 
| 24 | 
            -
                        when String
         | 
| 25 | 
            -
                          Regexp.new("\\A#{Regexp.escape(pattern)}\\z")
         | 
| 26 | 
            -
                        else
         | 
| 27 | 
            -
                          pattern
         | 
| 28 | 
            -
                        end
         | 
| 29 | 
            -
                      end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                      def enable_styling!
         | 
| 32 | 
            -
                        self.styling_enabled = true
         | 
| 33 | 
            -
                      end
         | 
| 34 | 
            -
                    end
         | 
| 35 | 
            -
                  end
         | 
| 36 | 
            -
                end
         | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
            end
         | 
| @@ -1,192 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Writer
         | 
| 4 | 
            -
                  Error = Class.new(RuntimeError)
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                  def device
         | 
| 7 | 
            -
                    @device ||= StringIO.new
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
                  attr_writer :device
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                  attr_accessor :styling
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  def styling_enabled
         | 
| 14 | 
            -
                    instance_variable_defined?(:@styling_enabled) ?
         | 
| 15 | 
            -
                      @styling_enabled :
         | 
| 16 | 
            -
                      @styling_enabled = self.class.styling?(device, styling)
         | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
                  attr_writer :styling_enabled
         | 
| 19 | 
            -
                  alias_method :styling?, :styling_enabled
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                  def mode
         | 
| 22 | 
            -
                    @mode ||= Mode.text
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                  attr_writer :mode
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  def byte_offset
         | 
| 27 | 
            -
                    @byte_offset ||= 0
         | 
| 28 | 
            -
                  end
         | 
| 29 | 
            -
                  attr_writer :byte_offset
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                  def indentation_depth
         | 
| 32 | 
            -
                    @indentation_depth ||= 0
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
                  attr_writer :indentation_depth
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                  def configure(styling: nil, device: nil)
         | 
| 37 | 
            -
                    device ||= Defaults.device
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                    unless styling.nil?
         | 
| 40 | 
            -
                      self.class.assure_styling_setting(styling)
         | 
| 41 | 
            -
                    end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                    self.device = device
         | 
| 44 | 
            -
                    self.styling = styling
         | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                  def self.build(device=nil, styling: nil)
         | 
| 48 | 
            -
                    instance = new
         | 
| 49 | 
            -
                    instance.configure(device: device, styling: styling)
         | 
| 50 | 
            -
                    instance
         | 
| 51 | 
            -
                  end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                  def self.configure(receiver, writer: nil, styling: nil, device: nil, attr_name: nil)
         | 
| 54 | 
            -
                    attr_name ||= :writer
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                    if writer.nil?
         | 
| 57 | 
            -
                      instance = build(device, styling: styling)
         | 
| 58 | 
            -
                    else
         | 
| 59 | 
            -
                      instance = writer
         | 
| 60 | 
            -
                    end
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                    receiver.public_send(:"#{attr_name}=", instance)
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                    instance
         | 
| 65 | 
            -
                  end
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                  def text(text)
         | 
| 68 | 
            -
                    if mode == Mode.escape_sequence
         | 
| 69 | 
            -
                      self.mode = Mode.text
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                      write('m')
         | 
| 72 | 
            -
                    end
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                    write(text)
         | 
| 75 | 
            -
             | 
| 76 | 
            -
                    self
         | 
| 77 | 
            -
                  end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                  def escape_code(id)
         | 
| 80 | 
            -
                    escape_code = SGR.escape_code(id)
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                    if mode == Mode.text
         | 
| 83 | 
            -
                      return self unless styling?
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                      self.mode = Mode.escape_sequence
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                      write("\e[")
         | 
| 88 | 
            -
                    else
         | 
| 89 | 
            -
                      write(';')
         | 
| 90 | 
            -
                    end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                    write(escape_code)
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                    self
         | 
| 95 | 
            -
                  end
         | 
| 96 | 
            -
             | 
| 97 | 
            -
                  def sync
         | 
| 98 | 
            -
                    text('')
         | 
| 99 | 
            -
                  end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                  def indent
         | 
| 102 | 
            -
                    indentation = '  ' * indentation_depth
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                    text(indentation)
         | 
| 105 | 
            -
                  end
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                  def newline
         | 
| 108 | 
            -
                    sync
         | 
| 109 | 
            -
                    device.puts('')
         | 
| 110 | 
            -
                    self.byte_offset += 1
         | 
| 111 | 
            -
                    self
         | 
| 112 | 
            -
                  end
         | 
| 113 | 
            -
             | 
| 114 | 
            -
                  def write(data)
         | 
| 115 | 
            -
                    bytes_written = device.write(data)
         | 
| 116 | 
            -
             | 
| 117 | 
            -
                    self.byte_offset += bytes_written
         | 
| 118 | 
            -
                  end
         | 
| 119 | 
            -
             | 
| 120 | 
            -
                  def current?(byte_offset)
         | 
| 121 | 
            -
                    byte_offset >= self.byte_offset
         | 
| 122 | 
            -
                  end
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                  def increase_indentation
         | 
| 125 | 
            -
                    self.indentation_depth += 1
         | 
| 126 | 
            -
                  end
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                  def decrease_indentation
         | 
| 129 | 
            -
                    self.indentation_depth -= 1
         | 
| 130 | 
            -
                  end
         | 
| 131 | 
            -
             | 
| 132 | 
            -
                  def self.styling?(device, styling_setting=nil)
         | 
| 133 | 
            -
                    styling_setting ||= Defaults.styling
         | 
| 134 | 
            -
             | 
| 135 | 
            -
                    assure_styling_setting(styling_setting)
         | 
| 136 | 
            -
             | 
| 137 | 
            -
                    case styling_setting
         | 
| 138 | 
            -
                    when :detect
         | 
| 139 | 
            -
                      device.tty?
         | 
| 140 | 
            -
                    when :on
         | 
| 141 | 
            -
                      true
         | 
| 142 | 
            -
                    when :off
         | 
| 143 | 
            -
                      false
         | 
| 144 | 
            -
                    end
         | 
| 145 | 
            -
                  end
         | 
| 146 | 
            -
             | 
| 147 | 
            -
                  def self.assure_styling_setting(styling_setting)
         | 
| 148 | 
            -
                    unless styling_settings.include?(styling_setting)
         | 
| 149 | 
            -
                      raise Error, "Invalid output styling #{styling_setting.inspect} (Valid values: #{styling_settings.map(&:inspect).join(', ')})"
         | 
| 150 | 
            -
                    end
         | 
| 151 | 
            -
                  end
         | 
| 152 | 
            -
             | 
| 153 | 
            -
                  def self.styling_settings
         | 
| 154 | 
            -
                    [
         | 
| 155 | 
            -
                      :detect,
         | 
| 156 | 
            -
                      :on,
         | 
| 157 | 
            -
                      :off
         | 
| 158 | 
            -
                    ]
         | 
| 159 | 
            -
                  end
         | 
| 160 | 
            -
             | 
| 161 | 
            -
                  def self.default_styling_setting
         | 
| 162 | 
            -
                    styling_settings.fetch(0)
         | 
| 163 | 
            -
                  end
         | 
| 164 | 
            -
             | 
| 165 | 
            -
                  module Mode
         | 
| 166 | 
            -
                    def self.text
         | 
| 167 | 
            -
                      :text
         | 
| 168 | 
            -
                    end
         | 
| 169 | 
            -
             | 
| 170 | 
            -
                    def self.escape_sequence
         | 
| 171 | 
            -
                      :escape_sequence
         | 
| 172 | 
            -
                    end
         | 
| 173 | 
            -
                  end
         | 
| 174 | 
            -
             | 
| 175 | 
            -
                  module Defaults
         | 
| 176 | 
            -
                    def self.device
         | 
| 177 | 
            -
                      $stdout
         | 
| 178 | 
            -
                    end
         | 
| 179 | 
            -
             | 
| 180 | 
            -
                    def self.styling
         | 
| 181 | 
            -
                      styling = ::ENV['TEST_BENCH_OUTPUT_STYLING']
         | 
| 182 | 
            -
             | 
| 183 | 
            -
                      if styling.nil?
         | 
| 184 | 
            -
                        Writer.default_styling_setting
         | 
| 185 | 
            -
                      else
         | 
| 186 | 
            -
                        styling.to_sym
         | 
| 187 | 
            -
                      end
         | 
| 188 | 
            -
                    end
         | 
| 189 | 
            -
                  end
         | 
| 190 | 
            -
                end
         | 
| 191 | 
            -
              end
         | 
| 192 | 
            -
            end
         | 
    
        data/lib/test_bench/output.rb
    DELETED
    
    | @@ -1,21 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                def self.build(log_level: nil, writer: nil, device: nil, styling: nil, **buffer_output_args)
         | 
| 4 | 
            -
                  summary = Summary.build(writer: writer, device: device, styling: styling)
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                  log_output = Log.build(level: log_level)
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  writer = summary.writer
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  buffer_output = Buffer.build(writer: writer, **buffer_output_args)
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  Fixture::Output::Multiple.build(
         | 
| 13 | 
            -
                    log_output,
         | 
| 14 | 
            -
                    buffer_output,
         | 
| 15 | 
            -
                    summary
         | 
| 16 | 
            -
                  )
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                Substitute = Fixture::Output::Substitute
         | 
| 20 | 
            -
              end
         | 
| 21 | 
            -
            end
         | 
| @@ -1,36 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              class Run
         | 
| 3 | 
            -
                module Substitute
         | 
| 4 | 
            -
                  def self.build
         | 
| 5 | 
            -
                    Run.new
         | 
| 6 | 
            -
                  end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                  class Run
         | 
| 9 | 
            -
                    attr_accessor :ran
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    def paths
         | 
| 12 | 
            -
                      @paths ||= []
         | 
| 13 | 
            -
                    end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                    def call(&block)
         | 
| 16 | 
            -
                      self.ran = true
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                      block.(self) unless block.nil?
         | 
| 19 | 
            -
                    end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                    def path(path)
         | 
| 22 | 
            -
                      paths << path
         | 
| 23 | 
            -
                    end
         | 
| 24 | 
            -
                    alias_method :<<, :path
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                    def ran?(*paths)
         | 
| 27 | 
            -
                      return false unless ran
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                      paths.all? do |path|
         | 
| 30 | 
            -
                        self.paths.include?(path)
         | 
| 31 | 
            -
                      end
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
              end
         | 
| 36 | 
            -
            end
         | 
    
        data/lib/test_bench/run.rb
    DELETED
    
    | @@ -1,113 +0,0 @@ | |
| 1 | 
            -
            module TestBench
         | 
| 2 | 
            -
              class Run
         | 
| 3 | 
            -
                Error = Class.new(RuntimeError)
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                def session
         | 
| 6 | 
            -
                  @session ||= Fixture::Session::Substitute.build
         | 
| 7 | 
            -
                end
         | 
| 8 | 
            -
                attr_writer :session
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                def exclude_pattern
         | 
| 11 | 
            -
                  @exclude_pattern ||= Defaults.exclude_pattern
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
                attr_writer :exclude_pattern
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                attr_reader :paths
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                def initialize(*paths)
         | 
| 18 | 
            -
                  @paths = Array(paths)
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                def self.build(*paths, exclude: nil, session: nil, output: nil)
         | 
| 22 | 
            -
                  session ||= TestBench.session
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                  instance = new(*paths)
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  instance.exclude_pattern = exclude unless exclude.nil?
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                  Fixture::Session.configure(instance, session: session)
         | 
| 29 | 
            -
                  instance.session.output = output unless output.nil?
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                  instance
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                def self.configure(receiver, *paths, attr_name: nil, **args)
         | 
| 35 | 
            -
                  attr_name ||= :run
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                  instance = build(*paths, **args)
         | 
| 38 | 
            -
                  receiver.public_send(:"#{attr_name}=", instance)
         | 
| 39 | 
            -
                  instance
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                def self.call(*paths, session: nil, **args, &block)
         | 
| 43 | 
            -
                  instance = build(*paths, session: session, **args)
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                  if block.nil?
         | 
| 46 | 
            -
                    instance.()
         | 
| 47 | 
            -
                  else
         | 
| 48 | 
            -
                    instance.() do
         | 
| 49 | 
            -
                      unless session.nil?
         | 
| 50 | 
            -
                        original_session = TestBench.session
         | 
| 51 | 
            -
                        TestBench.session = session
         | 
| 52 | 
            -
                      end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                      block.(instance)
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                    ensure
         | 
| 57 | 
            -
                      unless original_session.nil?
         | 
| 58 | 
            -
                        TestBench.session = original_session
         | 
| 59 | 
            -
                      end
         | 
| 60 | 
            -
                    end
         | 
| 61 | 
            -
                  end
         | 
| 62 | 
            -
                end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                def call(&block)
         | 
| 65 | 
            -
                  session.start
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                  if block.nil?
         | 
| 68 | 
            -
                    paths.each do |path|
         | 
| 69 | 
            -
                      path(path)
         | 
| 70 | 
            -
                    end
         | 
| 71 | 
            -
                  else
         | 
| 72 | 
            -
                    block.()
         | 
| 73 | 
            -
                  end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                ensure
         | 
| 76 | 
            -
                  session.finish
         | 
| 77 | 
            -
                end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                def path(path)
         | 
| 80 | 
            -
                  if File.directory?(path)
         | 
| 81 | 
            -
                    directory(path)
         | 
| 82 | 
            -
                  elsif File.exist?(path)
         | 
| 83 | 
            -
                    file(path)
         | 
| 84 | 
            -
                  else
         | 
| 85 | 
            -
                    raise Error, "Path not found (Path: #{path.inspect})"
         | 
| 86 | 
            -
                  end
         | 
| 87 | 
            -
                end
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                def directory(path)
         | 
| 90 | 
            -
                  glob_pattern = File.join(path, '**/*.rb')
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                  Dir.glob(glob_pattern).sort.each do |path|
         | 
| 93 | 
            -
                    file(path)
         | 
| 94 | 
            -
                  end
         | 
| 95 | 
            -
                end
         | 
| 96 | 
            -
             | 
| 97 | 
            -
                def file(path)
         | 
| 98 | 
            -
                  unless exclude_pattern.match?(path)
         | 
| 99 | 
            -
                    session.load(path)
         | 
| 100 | 
            -
                  end
         | 
| 101 | 
            -
                end
         | 
| 102 | 
            -
             | 
| 103 | 
            -
                module Defaults
         | 
| 104 | 
            -
                  def self.exclude_pattern
         | 
| 105 | 
            -
                    pattern = ENV.fetch('TEST_BENCH_EXCLUDE_FILE_PATTERN') do
         | 
| 106 | 
            -
                      '_init.rb$'
         | 
| 107 | 
            -
                    end
         | 
| 108 | 
            -
             | 
| 109 | 
            -
                    Regexp.new(pattern)
         | 
| 110 | 
            -
                  end
         | 
| 111 | 
            -
                end
         | 
| 112 | 
            -
              end
         | 
| 113 | 
            -
            end
         | 
    
        data/script/bench
    DELETED
    
    | @@ -1,19 +0,0 @@ | |
| 1 | 
            -
            #!/usr/bin/env ruby
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            begin
         | 
| 4 | 
            -
              require 'test_bench'
         | 
| 5 | 
            -
            rescue LoadError => load_error
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            unless load_error.nil?
         | 
| 9 | 
            -
              if File.exist?('init.rb')
         | 
| 10 | 
            -
                require_relative '../init.rb'
         | 
| 11 | 
            -
                require 'test_bench'
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                ENV['BOOTSTRAP'] ||= 'off'
         | 
| 14 | 
            -
              else
         | 
| 15 | 
            -
                raise load_error
         | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
            end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            TestBench::CLI.()
         |