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
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 929185b5e91b95d52c3f5f118b7e38967ada55759d4f12b1e298ce44604f5dfb
         | 
| 4 | 
            +
              data.tar.gz: af4a0aa5829a85bf41976eb16bbc41e8ce991517749130105d2ebedda13e168a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 80f71eaeee2781b7408e40bd98570753beb40ebf0855481049bb7fa1f5675ead28e337d3d510b334559a470dd8b268bd1cb32a09bc78dbf28535643e9c884c3a
         | 
| 7 | 
            +
              data.tar.gz: 578d27227eba55273bd47bd7a5802ad8d12b2806cc0dbff5caac79b325013053a1d70350b24e2331ebb8a66b870afa24e414961c3af8124a932fdc63527553a8
         | 
    
        data/lib/test_bench/cli.rb
    CHANGED
    
    | @@ -1,43 +1,293 @@ | |
| 1 1 | 
             
            module TestBench
         | 
| 2 | 
            -
               | 
| 3 | 
            -
                 | 
| 4 | 
            -
                  tests_directory ||= Defaults.tests_directory
         | 
| 2 | 
            +
              class CLI
         | 
| 3 | 
            +
                ArgumentError = Class.new(RuntimeError)
         | 
| 5 4 |  | 
| 6 | 
            -
             | 
| 5 | 
            +
                attr_reader :arguments
         | 
| 7 6 |  | 
| 8 | 
            -
             | 
| 7 | 
            +
                attr_accessor :exit_code
         | 
| 9 8 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 9 | 
            +
                def env
         | 
| 10 | 
            +
                  @env ||= {}
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
                attr_writer :env
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def program_name
         | 
| 15 | 
            +
                  @program_name ||= Defaults.program_name
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
                attr_writer :program_name
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def version
         | 
| 20 | 
            +
                  @version ||= Defaults.version
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
                attr_writer :version
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def stdin
         | 
| 25 | 
            +
                  @stdin ||= STDIN
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
                attr_writer :stdin
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def writer
         | 
| 30 | 
            +
                  @writer ||= Output::Writer::Substitute.build
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
                attr_writer :writer
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def run
         | 
| 35 | 
            +
                  @run ||= Run::Substitute.build
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
                attr_writer :run
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def random
         | 
| 40 | 
            +
                  @random ||= Random::Substitute.build
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
                attr_writer :random
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def initialize(*arguments)
         | 
| 45 | 
            +
                  @arguments = arguments
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                def self.build(arguments=nil, env: nil)
         | 
| 49 | 
            +
                  arguments ||= ::ARGV
         | 
| 50 | 
            +
                  env ||= ::ENV
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  instance = new(*arguments)
         | 
| 53 | 
            +
                  instance.env = env
         | 
| 54 | 
            +
                  Output::Writer.configure(instance)
         | 
| 55 | 
            +
                  Run.configure(instance)
         | 
| 56 | 
            +
                  instance
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                def self.call(arguments=nil, env: nil)
         | 
| 60 | 
            +
                  instance = build(arguments, env:)
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  session = instance.run.session
         | 
| 63 | 
            +
                  Session::Store.reset(session)
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  instance.()
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                def call
         | 
| 69 | 
            +
                  parse_arguments
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  if exit_code?
         | 
| 72 | 
            +
                    return exit_code
         | 
| 12 73 | 
             
                  end
         | 
| 13 74 |  | 
| 14 | 
            -
                   | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 75 | 
            +
                  writer.puts(RUBY_DESCRIPTION)
         | 
| 76 | 
            +
                  writer.puts("Random Seed: #{random.seed.to_s(36)}")
         | 
| 77 | 
            +
                  writer.puts
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  default_path = Defaults.tests_directory
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  result = run.! do |run|
         | 
| 82 | 
            +
                    if not stdin.tty?
         | 
| 83 | 
            +
                      until stdin.eof?
         | 
| 84 | 
            +
                        path = stdin.gets(chomp: true)
         | 
| 18 85 |  | 
| 19 86 | 
             
                        next if path.empty?
         | 
| 20 87 |  | 
| 21 | 
            -
                        run | 
| 88 | 
            +
                        run << path
         | 
| 22 89 | 
             
                      end
         | 
| 23 90 | 
             
                    end
         | 
| 24 91 |  | 
| 25 | 
            -
                     | 
| 26 | 
            -
                       | 
| 27 | 
            -
             | 
| 92 | 
            +
                    arguments.each do |path|
         | 
| 93 | 
            +
                      run << path
         | 
| 94 | 
            +
                    end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                    if not run.ran?
         | 
| 97 | 
            +
                      run << default_path
         | 
| 98 | 
            +
                    end
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                  self.exit_code = self.class.exit_code(result)
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  exit_code
         | 
| 104 | 
            +
                end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                def parse_arguments
         | 
| 107 | 
            +
                  argument_index = 0
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                  until argument_index == arguments.count
         | 
| 110 | 
            +
                    next_argument = next_argument(argument_index)
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                    if not next_argument.start_with?('-')
         | 
| 113 | 
            +
                      argument_index += 1
         | 
| 114 | 
            +
                      next
         | 
| 115 | 
            +
                    end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                    switch = next_argument!(argument_index)
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                    case switch
         | 
| 120 | 
            +
                    when '--'
         | 
| 121 | 
            +
                      break
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                    when '-h', '--help'
         | 
| 124 | 
            +
                      print_help_text
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                      self.exit_code = 0
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                    when '-v', '--version'
         | 
| 129 | 
            +
                      writer.puts "TestBench Version: #{version}"
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                      self.exit_code = 0
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                    when '-d', '--detail', '--no-detail'
         | 
| 134 | 
            +
                      if not negated?(switch)
         | 
| 135 | 
            +
                        detail_policy_text = 'on'
         | 
| 136 | 
            +
                      else
         | 
| 137 | 
            +
                        detail_policy_text = 'off'
         | 
| 28 138 | 
             
                      end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                       | 
| 31 | 
            -
             | 
| 139 | 
            +
             | 
| 140 | 
            +
                      detail_policy = detail_policy_text.to_sym
         | 
| 141 | 
            +
                      Session::Output::Detail.assure_detail(detail_policy)
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                      env['TEST_BENCH_DETAIL'] = detail_policy_text
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                    when '-x', '--exclude', '--no-exclude'
         | 
| 146 | 
            +
                      if not negated?(switch)
         | 
| 147 | 
            +
                        exclude_file_pattern_text = switch_value!(argument_index, switch)
         | 
| 148 | 
            +
                      else
         | 
| 149 | 
            +
                        exclude_file_pattern_text = ''
         | 
| 150 | 
            +
                      end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                      env['TEST_BENCH_EXCLUDE_FILE_PATTERN'] = exclude_file_pattern_text
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                    when '-f', '--only-failure', '--no-only-failure'
         | 
| 155 | 
            +
                      if not negated?(switch)
         | 
| 156 | 
            +
                        only_failure_text = 'on'
         | 
| 157 | 
            +
                      else
         | 
| 158 | 
            +
                        only_failure_text = 'off'
         | 
| 159 | 
            +
                      end
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                      env['TEST_BENCH_ONLY_FAILURE'] = only_failure_text
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                    when '-o', '--output-styling'
         | 
| 164 | 
            +
                      output_styling_text = switch_value(argument_index) do
         | 
| 165 | 
            +
                        'on'
         | 
| 32 166 | 
             
                      end
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                      output_styling = output_styling_text.to_sym
         | 
| 169 | 
            +
                      Output::Writer::Styling.assure_styling(output_styling)
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                      env['TEST_BENCH_OUTPUT_STYLING'] = output_styling_text
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                    when '-s', '--seed'
         | 
| 174 | 
            +
                      seed_text = switch_value!(argument_index, switch)
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                      begin
         | 
| 177 | 
            +
                        Integer(seed_text)
         | 
| 178 | 
            +
                      rescue
         | 
| 179 | 
            +
                        raise ArgumentError, "Seed switch must be an integer (Seed: #{seed_text.inspect})"
         | 
| 180 | 
            +
                      end
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                      env['TEST_BENCH_SEED'] = seed_text
         | 
| 183 | 
            +
             | 
| 184 | 
            +
                    when '-r', '--require'
         | 
| 185 | 
            +
                      library = switch_value!(argument_index, switch)
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                      require library
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                    else
         | 
| 190 | 
            +
                      raise ArgumentError, "Unknown switch #{switch.inspect}"
         | 
| 33 191 | 
             
                    end
         | 
| 34 192 | 
             
                  end
         | 
| 35 193 | 
             
                end
         | 
| 36 194 |  | 
| 195 | 
            +
                def print_help_text
         | 
| 196 | 
            +
                  writer.write <<~TEXT
         | 
| 197 | 
            +
                  Usage: #{program_name} [options] [paths]
         | 
| 198 | 
            +
             | 
| 199 | 
            +
                  Informational Options:
         | 
| 200 | 
            +
                  \t-h, --help                        Print this help message and exit successfully
         | 
| 201 | 
            +
                  \t-v, --version                     Print version and exit successfully
         | 
| 202 | 
            +
             | 
| 203 | 
            +
                  Configuration Options:
         | 
| 204 | 
            +
                  \t-d, --[no]detail                  Always show (or hide) details (Default: #{Session::Output::Detail.default})
         | 
| 205 | 
            +
                  \t-x, --[no-]exclude PATTERN        Do not execute test files matching PATTERN (Default: #{Run::GetFiles::Defaults.exclude_file_pattern.inspect})
         | 
| 206 | 
            +
                  \t-f, --[no-]only-failure           Don't display output for test files that pass (Default: #{Run::Output::File::Defaults.only_failure ? 'on' : 'off'})
         | 
| 207 | 
            +
                  \t-o, --output-styling [on|off|detect]
         | 
| 208 | 
            +
                  \t                                  Render output coloring and font styling escape codes (Default: #{Output::Writer::Styling.default})
         | 
| 209 | 
            +
                  \t-s, --seed NUMBER                 Sets pseudo-random number seed (Default: not set)
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                  Other Options:
         | 
| 212 | 
            +
                  \t-r, --require LIBRARY             Require LIBRARY before running any files
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                  Paths to test files (and directories containing test files) can be given after any command line arguments or via STDIN (or both).
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                  If no paths are given, a default path (#{Defaults.tests_directory}) is scanned for test files.
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                  The following environment variables can also control execution:
         | 
| 219 | 
            +
             | 
| 220 | 
            +
                  \tTEST_BENCH_DETAIL                 Same as -d or --detail
         | 
| 221 | 
            +
                  \tTEST_BENCH_EXCLUDE_FILE_PATTERN   Same as -x or --exclude-file-pattern
         | 
| 222 | 
            +
                  \tTEST_BENCH_ONLY_FAILURE           Same as -f or --only-failure
         | 
| 223 | 
            +
                  \tTEST_BENCH_OUTPUT_STYLING         Same as -o or --output-styling
         | 
| 224 | 
            +
                  \tTEST_BENCH_SEED                   Same as -s or --seed
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                  TEXT
         | 
| 227 | 
            +
                end
         | 
| 228 | 
            +
             | 
| 229 | 
            +
                def negated?(switch)
         | 
| 230 | 
            +
                  switch.start_with?('--no-')
         | 
| 231 | 
            +
                end
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                def exit_code?
         | 
| 234 | 
            +
                  !exit_code.nil?
         | 
| 235 | 
            +
                end
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                def switch_value!(argument_index, argument)
         | 
| 238 | 
            +
                  switch_value(argument_index) do
         | 
| 239 | 
            +
                    raise ArgumentError, "Argument #{argument.inspect} requires an argument"
         | 
| 240 | 
            +
                  end
         | 
| 241 | 
            +
                end
         | 
| 242 | 
            +
             | 
| 243 | 
            +
                def switch_value(argument_index, &no_value_action)
         | 
| 244 | 
            +
                  next_value = next_argument(argument_index)
         | 
| 245 | 
            +
             | 
| 246 | 
            +
                  if next_value.nil? || next_value.start_with?('-')
         | 
| 247 | 
            +
                    switch_value = nil
         | 
| 248 | 
            +
             | 
| 249 | 
            +
                    return no_value_action.()
         | 
| 250 | 
            +
                  else
         | 
| 251 | 
            +
                    switch_value = next_argument!(argument_index)
         | 
| 252 | 
            +
             | 
| 253 | 
            +
                    return switch_value
         | 
| 254 | 
            +
                  end
         | 
| 255 | 
            +
                end
         | 
| 256 | 
            +
             | 
| 257 | 
            +
                def next_argument(argument_index)
         | 
| 258 | 
            +
                  arguments[argument_index]
         | 
| 259 | 
            +
                end
         | 
| 260 | 
            +
             | 
| 261 | 
            +
                def next_argument!(argument_index)
         | 
| 262 | 
            +
                  arguments.delete_at(argument_index)
         | 
| 263 | 
            +
                end
         | 
| 264 | 
            +
             | 
| 265 | 
            +
                def self.exit_code(result)
         | 
| 266 | 
            +
                  if result == true
         | 
| 267 | 
            +
                    0
         | 
| 268 | 
            +
                  elsif result == false
         | 
| 269 | 
            +
                    1
         | 
| 270 | 
            +
                  else
         | 
| 271 | 
            +
                    2
         | 
| 272 | 
            +
                  end
         | 
| 273 | 
            +
                end
         | 
| 274 | 
            +
             | 
| 37 275 | 
             
                module Defaults
         | 
| 38 276 | 
             
                  def self.tests_directory
         | 
| 39 277 | 
             
                    ENV.fetch('TEST_BENCH_TESTS_DIRECTORY', 'test/automated')
         | 
| 40 278 | 
             
                  end
         | 
| 279 | 
            +
             | 
| 280 | 
            +
                  def self.program_name
         | 
| 281 | 
            +
                    $PROGRAM_NAME || 'bench'
         | 
| 282 | 
            +
                  end
         | 
| 283 | 
            +
             | 
| 284 | 
            +
                  def self.version
         | 
| 285 | 
            +
                    if Object.const_defined?(:Gem)
         | 
| 286 | 
            +
                      spec = Gem.loaded_specs['test_bench']
         | 
| 287 | 
            +
                    end
         | 
| 288 | 
            +
             | 
| 289 | 
            +
                    spec&.version || '(unknown)'
         | 
| 290 | 
            +
                  end
         | 
| 41 291 | 
             
                end
         | 
| 42 292 | 
             
              end
         | 
| 43 293 | 
             
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            module TestBench
         | 
| 2 | 
            +
              module Controls
         | 
| 3 | 
            +
                module Stdin
         | 
| 4 | 
            +
                  module Create
         | 
| 5 | 
            +
                    def self.call(*paths)
         | 
| 6 | 
            +
                      if paths.empty?
         | 
| 7 | 
            +
                        paths = Path.examples
         | 
| 8 | 
            +
                      end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                      contents = <<~TEXT
         | 
| 11 | 
            +
                      #{paths.join("\n")}
         | 
| 12 | 
            +
                      TEXT
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                      file = File::Create.(contents:)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                      ::File.open(file, 'r')
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    def self.contents
         | 
| 20 | 
            +
                      <<~TEXT
         | 
| 21 | 
            +
                      #{Path.example}
         | 
| 22 | 
            +
                      TEXT
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/lib/test_bench/controls.rb
    CHANGED
    
    | @@ -1,28 +1,11 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            end
         | 
| 1 | 
            +
            require 'test_bench/random/controls'
         | 
| 2 | 
            +
            require 'test_bench/run/controls'
         | 
| 4 3 |  | 
| 5 | 
            -
            require 'test_bench/ | 
| 4 | 
            +
            require 'test_bench/controls/result'
         | 
| 6 5 |  | 
| 7 | 
            -
            require 'test_bench/controls/caller_location'
         | 
| 8 | 
            -
            require 'test_bench/controls/depth'
         | 
| 9 | 
            -
            require 'test_bench/controls/device'
         | 
| 10 | 
            -
            require 'test_bench/controls/directory'
         | 
| 11 | 
            -
            require 'test_bench/controls/error'
         | 
| 12 | 
            -
            require 'test_bench/controls/fixture'
         | 
| 13 6 | 
             
            require 'test_bench/controls/path'
         | 
| 14 | 
            -
            require 'test_bench/controls/pattern'
         | 
| 15 | 
            -
            require 'test_bench/controls/result'
         | 
| 16 | 
            -
            require 'test_bench/controls/test_file'
         | 
| 17 | 
            -
            require 'test_bench/controls/time'
         | 
| 18 7 |  | 
| 19 | 
            -
            require 'test_bench/controls/ | 
| 20 | 
            -
            require 'test_bench/controls/ | 
| 21 | 
            -
             | 
| 22 | 
            -
            require 'test_bench/controls/ | 
| 23 | 
            -
            require 'test_bench/controls/output/exercise'
         | 
| 24 | 
            -
            require 'test_bench/controls/output/summary/session'
         | 
| 25 | 
            -
            require 'test_bench/controls/output/summary/error'
         | 
| 26 | 
            -
            require 'test_bench/controls/output/batch_data'
         | 
| 27 | 
            -
            require 'test_bench/controls/output/detail_setting'
         | 
| 28 | 
            -
            require 'test_bench/controls/output/log_level'
         | 
| 8 | 
            +
            require 'test_bench/controls/file'
         | 
| 9 | 
            +
            require 'test_bench/controls/stdin'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            require 'test_bench/controls/random'
         | 
| @@ -1,104 +1,50 @@ | |
| 1 1 | 
             
            module TestBench
         | 
| 2 | 
            -
              def self. | 
| 3 | 
            -
                @session ||= build_session.tap do |session|
         | 
| 4 | 
            -
                  at_exit do
         | 
| 5 | 
            -
                    exit_code = exit_code(session)
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                    exit(exit_code) unless exit_code.zero?
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
                end
         | 
| 10 | 
            -
              end
         | 
| 11 | 
            -
              singleton_class.attr_writer(:session)
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              def self.output
         | 
| 14 | 
            -
                session.output
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
              def self.set_output(output, session: nil)
         | 
| 18 | 
            -
                session ||= self.session
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                if output.is_a?(Array)
         | 
| 21 | 
            -
                  output = Fixture::Output::Multiple.build(*output)
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                session.output = output
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
              singleton_class.alias_method :output=, :set_output
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              def self.activate(receiver=nil, session: nil)
         | 
| 2 | 
            +
              def self.activate(receiver=nil, session_store: nil)
         | 
| 29 3 | 
             
                receiver ||= TOPLEVEL_BINDING.receiver
         | 
| 4 | 
            +
                session_store ||= Session::Store.instance
         | 
| 30 5 |  | 
| 31 | 
            -
                 | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
              def self.evaluate(session: nil, &block)
         | 
| 35 | 
            -
                fixture = fixture(session)
         | 
| 6 | 
            +
                receiver.extend(Fixture)
         | 
| 7 | 
            +
                receiver.extend(DeactivatedVariants)
         | 
| 36 8 |  | 
| 37 | 
            -
                 | 
| 38 | 
            -
             | 
| 39 | 
            -
                end
         | 
| 9 | 
            +
                receiver.extend(TestSession)
         | 
| 10 | 
            +
                receiver.test_session_store = session_store
         | 
| 40 11 | 
             
              end
         | 
| 41 12 |  | 
| 42 13 | 
             
              def self.context(title=nil, session: nil, &block)
         | 
| 43 | 
            -
                evaluate(session: | 
| 14 | 
            +
                evaluate(session:) do
         | 
| 44 15 | 
             
                  context(title) do
         | 
| 45 16 | 
             
                    instance_exec(&block)
         | 
| 46 17 | 
             
                  end
         | 
| 47 18 | 
             
                end
         | 
| 48 19 | 
             
              end
         | 
| 49 20 |  | 
| 50 | 
            -
              def self. | 
| 51 | 
            -
                 | 
| 52 | 
            -
                 | 
| 53 | 
            -
             | 
| 54 | 
            -
                receiver.extend(Fixture)
         | 
| 55 | 
            -
                receiver.extend(DeactivationVariants)
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                receiver.test_session = session
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                receiver
         | 
| 60 | 
            -
              end
         | 
| 61 | 
            -
             | 
| 62 | 
            -
              def self.build_session(output: nil, abort_on_error: nil, **args)
         | 
| 63 | 
            -
                output ||= Output.build
         | 
| 64 | 
            -
                error_policy = session_error_policy(abort_on_error)
         | 
| 21 | 
            +
              def self.evaluate(session: nil, &block)
         | 
| 22 | 
            +
                fixture = TestBench::Fixture::Evaluate.build(session:, &block)
         | 
| 23 | 
            +
                fixture.extend(DeactivatedVariants)
         | 
| 24 | 
            +
                fixture.()
         | 
| 65 25 |  | 
| 66 | 
            -
                 | 
| 26 | 
            +
                fixture.test_session.passed?
         | 
| 67 27 | 
             
              end
         | 
| 68 28 |  | 
| 69 | 
            -
              def self. | 
| 70 | 
            -
                 | 
| 71 | 
            -
             | 
| 72 | 
            -
                if abort_on_error
         | 
| 73 | 
            -
                  :abort
         | 
| 74 | 
            -
                else
         | 
| 75 | 
            -
                  :rescue
         | 
| 76 | 
            -
                end
         | 
| 29 | 
            +
              def self.session
         | 
| 30 | 
            +
                Session::Store.get
         | 
| 77 31 | 
             
              end
         | 
| 78 32 |  | 
| 79 | 
            -
               | 
| 80 | 
            -
                 | 
| 81 | 
            -
                   | 
| 33 | 
            +
              module DeactivatedVariants
         | 
| 34 | 
            +
                def _context(title=nil, &)
         | 
| 35 | 
            +
                  context(title)
         | 
| 82 36 | 
             
                end
         | 
| 83 37 |  | 
| 84 | 
            -
                 | 
| 85 | 
            -
                   | 
| 86 | 
            -
                elsif session.skipped?
         | 
| 87 | 
            -
                  fail_deactivated_tests ? 2 : 0
         | 
| 88 | 
            -
                else
         | 
| 89 | 
            -
                  0
         | 
| 38 | 
            +
                def _test(title=nil, &)
         | 
| 39 | 
            +
                  test(title)
         | 
| 90 40 | 
             
                end
         | 
| 91 41 | 
             
              end
         | 
| 92 42 |  | 
| 93 | 
            -
               | 
| 94 | 
            -
             | 
| 95 | 
            -
              module Defaults
         | 
| 96 | 
            -
                def self.abort_on_error
         | 
| 97 | 
            -
                  Environment::Boolean.fetch('TEST_BENCH_ABORT_ON_ERROR', false)
         | 
| 98 | 
            -
                end
         | 
| 43 | 
            +
              module TestSession
         | 
| 44 | 
            +
                attr_accessor :test_session_store
         | 
| 99 45 |  | 
| 100 | 
            -
                def  | 
| 101 | 
            -
                   | 
| 46 | 
            +
                def test_session
         | 
| 47 | 
            +
                  test_session_store.fetch
         | 
| 102 48 | 
             
                end
         | 
| 103 49 | 
             
              end
         | 
| 104 50 | 
             
            end
         | 
    
        data/lib/test_bench.rb
    CHANGED
    
    | @@ -1,39 +1,5 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
              require 'optionparser'
         | 
| 3 | 
            -
            end
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            require 'test_bench/fixture'
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            require 'test_bench/environment/boolean'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            require 'test_bench/output/writer'
         | 
| 10 | 
            -
            require 'test_bench/output/writer/sgr'
         | 
| 11 | 
            -
            require 'test_bench/output/writer/substitute'
         | 
| 12 | 
            -
            require 'test_bench/output/writer/dependency'
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            require 'test_bench/output/timer'
         | 
| 15 | 
            -
            require 'test_bench/output/timer/substitute'
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            require 'test_bench/output/print_error'
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            require 'test_bench/output/summary'
         | 
| 20 | 
            -
            require 'test_bench/output/summary/session'
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            require 'test_bench/output/batch_data'
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            require 'test_bench/output/raw'
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            require 'test_bench/output/buffer'
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            require 'test_bench/output/log'
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            require 'test_bench/output'
         | 
| 1 | 
            +
            require 'test_bench/run'
         | 
| 31 2 |  | 
| 32 3 | 
             
            require 'test_bench/test_bench'
         | 
| 33 | 
            -
            require 'test_bench/deactivation_variants'
         | 
| 34 | 
            -
             | 
| 35 | 
            -
            require 'test_bench/run'
         | 
| 36 | 
            -
            require 'test_bench/run/substitute'
         | 
| 37 4 |  | 
| 38 | 
            -
            require 'test_bench/cli/parse_arguments'
         | 
| 39 5 | 
             
            require 'test_bench/cli'
         |