<commit_before>require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec) do |t|
  t.pattern = 'spec/lib/**/*_spec.rb'
end

module Testing
  extend self

  def get_random_seed(env)
    random_seed = env['RANDOM_SEED'] ? env['RANDOM_SEED'] : rand(100_000)
    puts "export RANDOM_SEED=#{random_seed} # to re-use the same randomization"
    random_seed
  end

  module MSpec
    extend self

    def stubs
      %w[
        mspec/helpers/tmp
        mspec/helpers/environment
        mspec/guards/block_device
        mspec/guards/endian
        a_file
        lib/spec_helper
        mspec/commands/mspec-run
      ]
    end

    def specs(env = ENV)
      suite = env['SUITE']
      pattern = env['PATTERN']
      whitelist_pattern = !!env['RUBYSPECS']

      excepting = []
      rubyspecs = File.read('spec/ruby_specs').lines.reject do |l|
        l.strip!
        l.start_with?('#') || l.empty? || (l.start_with?('!') && excepting.push(l.sub('!', 'spec/') + '.rb'))
      end.flat_map do |path|
        path = "spec/#{path}"
        File.directory?(path) ? Dir[path+'/*.rb'] : "#{path}.rb"
      end - excepting

      opalspecs = Dir['spec/{opal,lib/parser}/**/*_spec.rb']
      userspecs = Dir[pattern] if pattern
      userspecs &= rubyspecs if whitelist_pattern

      specs = []
      add_specs = ->(name, new_specs) do
        puts "Adding #{new_specs.size.to_s.rjust(3)} files (#{name})"
        specs += new_specs
      end

      if pattern
        add_specs["PATTERN=#{pattern}", userspecs.sort]<commit_msg>Stub the `etc` stdlib file during the MSpec suite<commit_after>require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec) do |t|
  t.pattern = 'spec/lib/**/*_spec.rb'
end

module Testing
  extend self

  def get_random_seed(env)
    random_seed = env['RANDOM_SEED'] ? env['RANDOM_SEED'] : rand(100_000)
    puts "export RANDOM_SEED=#{random_seed} # to re-use the same randomization"
    random_seed
  end

  module MSpec
    extend self

    def stubs
      %w[
        mspec/helpers/tmp
        mspec/helpers/environment
        mspec/guards/block_device
        mspec/guards/endian
        a_file
        lib/spec_helper
        mspec/commands/mspec-run
        etc
      ]
    end

    def specs(env = ENV)
      suite = env['SUITE']
      pattern = env['PATTERN']
      whitelist_pattern = !!env['RUBYSPECS']

      excepting = []
      rubyspecs = File.read('spec/ruby_specs').lines.reject do |l|
        l.strip!
        l.start_with?('#') || l.empty? || (l.start_with?('!') && excepting.push(l.sub('!', 'spec/') + '.rb'))
      end.flat_map do |path|
        path = "spec/#{path}"
        File.directory?(path) ? Dir[path+'/*.rb'] : "#{path}.rb"
      end - excepting

      opalspecs = Dir['spec/{opal,lib/parser}/**/*_spec.rb']
      userspecs = Dir[pattern] if pattern
      userspecs &= rubyspecs if whitelist_pattern

      specs = []
      add_specs = ->(name, new_specs) do
        puts "Adding #{new_specs.size.to_s.rjust(3)} files (#{name})"
        specs += new_specs
      end

      if pattern
        add_specs["PATTERN=#{pattern}", userspecs.sort]
{'fraction_non_alphanumeric': 0.14967741935483872, 'fraction_numerical': 0.004516129032258065, 'mean_word_length': 2.507918552036199, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1157827', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1109, 'n_words': 210}