<commit_before>module KnapsackPro
  module Runners
    module Queue
      class RSpecRunner < BaseRunner
        def self.run(args)
          require 'rspec/core'

          ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_rspec
          ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
          ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id

          runner = new(KnapsackPro::Adapters::RSpecAdapter)

          cli_args = (args || '').split
          run_tests(runner, true, cli_args, 0)
        end

        def self.run_tests(runner, can_initialize_queue, args, exitstatus)
          test_file_paths = runner.test_file_paths(can_initialize_queue: can_initialize_queue)

          if test_file_paths.empty?
            KnapsackPro::Report.save_node_queue_to_api
            exit(exitstatus)
          else
            subset_queue_id = KnapsackPro::Config::EnvGenerator.set_subset_queue_id
            ENV['KNAPSACK_PRO_SUBSET_QUEUE_ID'] = subset_queue_id

            cli_args = args + [
              '--default-path', runner.test_dir,
            ] + test_file_paths
            options = RSpec::Core::ConfigurationOptions.new(cli_args)<commit_msg>Extract default path before recursion.<commit_after>module KnapsackPro
  module Runners
    module Queue
      class RSpecRunner < BaseRunner
        def self.run(args)
          require 'rspec/core'

          ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_rspec
          ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
          ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id

          runner = new(KnapsackPro::Adapters::RSpecAdapter)

          cli_args = (args || '').split + [
            '--default-path', runner.test_dir,
          ]
          run_tests(runner, true, cli_args, 0)
        end

        def self.run_tests(runner, can_initialize_queue, args, exitstatus)
          test_file_paths = runner.test_file_paths(can_initialize_queue: can_initialize_queue)

          if test_file_paths.empty?
            KnapsackPro::Report.save_node_queue_to_api
            exit(exitstatus)
          else
            subset_queue_id = KnapsackPro::Config::EnvGenerator.set_subset_queue_id
            ENV['KNAPSACK_PRO_SUBSET_QUEUE_ID'] = subset_queue_id

            cli_args = args + test_file_paths

            options = RSpec::Core::ConfigurationOptions.new(cli_args)
{'fraction_non_alphanumeric': 0.08697411003236245, 'fraction_numerical': 0.0008090614886731392, 'mean_word_length': 2.810477657935285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '405896', 'n_tokens_mistral': 809, 'n_tokens_neox': 774, 'n_words': 109}