<commit_before>module KnapsackPro
  class TestFileFinder
    def self.call(test_file_pattern, test_file_list_enabled: true)
      new(test_file_pattern, test_file_list_enabled).call
    end

    # finds slow test files on disk based on ENV patterns
    def self.slow_test_files_by_pattern(adapter_class)
      raise 'KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN not defined' unless KnapsackPro::Config::Env.slow_test_file_pattern

      test_file_pattern = TestFilePattern.call(adapter_class)
      test_file_paths = KnapsackPro::TestFileFinder.call(test_file_pattern)

      slow_test_file_paths = KnapsackPro::TestFileFinder.call(KnapsackPro::Config::Env.slow_test_file_pattern, test_file_list_enabled: false)

      # slow test files (KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN)
      # should be subset of test file pattern (KNAPSACK_PRO_TEST_FILE_PATTERN)
      slow_test_file_paths & test_file_paths
    end

    # Args:
    #   test_files - it can be list of slow test files that you want to run
    # Return:
    #   subset of test_files that are present on disk and it is subset of tests matching pattern KNAPSACK_PRO_TEST_FILE_PATTERN
    #   Thanks to that we can select only slow test files that are within list of test file pattern we want to run tests for
    def self.select_test_files_that_can_be_run(adapter_class, test_files)
      test_file_pattern = TestFilePattern.call(adapter_class)
      test_file_paths = KnapsackPro::TestFileFinder.call(test_file_pattern)

      test_file_paths_existing_on_disk = test_file_paths.map { |p| p.fetch('path') }

      selected_test_files = []

      test_files.each do |test_file|
        if test_file_paths_existing_on_disk.include?(test_file.fetch('path'))
          selected_test_files << test_file
        end
      end

      selected_test_files
    end

    def initialize(test_file_pattern, test_file_list_enabled)<commit_msg>Update test_file_finder.rb<commit_after>module KnapsackPro
  class TestFileFinder
    def self.call(test_file_pattern, test_file_list_enabled: true)
      new(test_file_pattern, test_file_list_enabled).call
    end

    # finds slow test files on disk based on ENV patterns
    def self.slow_test_files_by_pattern(adapter_class)
      raise 'KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN not defined' unless KnapsackPro::Config::Env.slow_test_file_pattern

      test_file_pattern = TestFilePattern.call(adapter_class)
      test_file_paths = KnapsackPro::TestFileFinder.call(test_file_pattern)

      slow_test_file_paths = KnapsackPro::TestFileFinder.call(KnapsackPro::Config::Env.slow_test_file_pattern, test_file_list_enabled: false)

      # slow test files (KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN)
      # should be subset of test file pattern (KNAPSACK_PRO_TEST_FILE_PATTERN)
      slow_test_file_paths & test_file_paths
    end

    # Args:
    #   test_files - it can be list of slow test files that you want to run
    # Return:
    #   subset of test_files that are present on disk and it is subset of tests matching pattern KNAPSACK_PRO_TEST_FILE_PATTERN
    #   Thanks to that we can select only slow test files that are within list of test file pattern we want to run tests for
    def self.select_test_files_that_can_be_run(adapter_class, test_files)
      test_file_pattern = TestFilePattern.call(adapter_class)
      test_file_paths = KnapsackPro::TestFileFinder.call(test_file_pattern)

      test_file_paths_existing_on_disk = KnapsackPro::TestFilePresenter.paths(test_file_paths)

      selected_test_files = []

      test_files.each do |test_file|
        if test_file_paths_existing_on_disk.include?(test_file.fetch('path'))
          selected_test_files << test_file
        end
      end

      selected_test_files
    end

    def initialize(test_file_pattern, test_file_list_enabled)
{'fraction_non_alphanumeric': 0.05515778308141077, 'fraction_numerical': 0.0, 'mean_word_length': 4.282913165266106, 'pattern_counts': {'":': 0, '<': 7, '<?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': '349208', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1186, 'n_words': 268}