<commit_before>module EvmTestHelper
  VMDB_SPECS        = FileList["spec/**/*_spec.rb"].exclude(/^spec\/(replication|gems|migrations|automation)/)
  METRICS_SPECS     = VMDB_SPECS + ['spec/coverage_helper.rb']
  REPLICATION_SPECS = FileList['spec/replication/**/*_spec.rb']
  MIGRATION_SPECS   = FileList['spec/migrations/**/*_spec.rb'].sort
  AUTOMATION_SPECS  = FileList['spec/automation/**/*_spec.rb']

  def self.init_rspec_task(t, rspec_opts = [])
    rspec_opts_file = ".rspec#{"_ci" if ENV['CI']}"
    t.rspec_opts = ['--options', "\"#{Rails.root.join(rspec_opts_file)}\""] + rspec_opts
    t.verbose = false
  end

  def self.run_rake_via_shell(rake_command, env = {})
    cmd = "bundle exec rake #{rake_command}"
    cmd << " --trace" if Rake.application.options.trace
    _pid, status = Process.wait2(Kernel.spawn(env, cmd, :chdir => Rails.root))
    exit(status.exitstatus) if status.exitstatus != 0
  end

  def self.cc_start_top
    return if $cc_top_parent_process_id
    if ENV['CC_BUILD_ARTIFACTS'] && File.exist?(ENV['CC_BUILD_ARTIFACTS'])
      dest = File.join(ENV['CC_BUILD_ARTIFACTS'], 'top_output.log')
      max_run_time = 2.hours
      top_interval = 30.seconds
      top_iterations = max_run_time / top_interval
      # top
      # -b batch mode
      # -d delay time between top runs(in seconds)
      # -n number of iterations
      $cc_top_parent_process_id = Process.pid
      system("top -b -d #{top_interval} -n #{top_iterations} >> #{dest} &")
      at_exit { system('killall top') if $cc_top_parent_process_id == Process.pid }<commit_msg>Allow rspec options from `.rspec` to be overridden<commit_after>module EvmTestHelper
  VMDB_SPECS        = FileList["spec/**/*_spec.rb"].exclude(/^spec\/(replication|gems|migrations|automation)/)
  METRICS_SPECS     = VMDB_SPECS + ['spec/coverage_helper.rb']
  REPLICATION_SPECS = FileList['spec/replication/**/*_spec.rb']
  MIGRATION_SPECS   = FileList['spec/migrations/**/*_spec.rb'].sort
  AUTOMATION_SPECS  = FileList['spec/automation/**/*_spec.rb']

  def self.init_rspec_task(t, rspec_opts = [])
    rspec_opts = ['--options', "\"#{Rails.root.join(".rspec_ci")}\""] + rspec_opts if ENV['CI']
    t.rspec_opts = rspec_opts
    t.verbose = false
  end

  def self.run_rake_via_shell(rake_command, env = {})
    cmd = "bundle exec rake #{rake_command}"
    cmd << " --trace" if Rake.application.options.trace
    _pid, status = Process.wait2(Kernel.spawn(env, cmd, :chdir => Rails.root))
    exit(status.exitstatus) if status.exitstatus != 0
  end

  def self.cc_start_top
    return if $cc_top_parent_process_id
    if ENV['CC_BUILD_ARTIFACTS'] && File.exist?(ENV['CC_BUILD_ARTIFACTS'])
      dest = File.join(ENV['CC_BUILD_ARTIFACTS'], 'top_output.log')
      max_run_time = 2.hours
      top_interval = 30.seconds
      top_iterations = max_run_time / top_interval
      # top
      # -b batch mode
      # -d delay time between top runs(in seconds)
      # -n number of iterations
      $cc_top_parent_process_id = Process.pid
      system("top -b -d #{top_interval} -n #{top_iterations} >> #{dest} &")
      at_exit { system('killall top') if $cc_top_parent_process_id == Process.pid }
{'fraction_non_alphanumeric': 0.1472819216182048, 'fraction_numerical': 0.0031605562579013905, 'mean_word_length': 3.7168405365126675, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1765438', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1143, 'n_words': 203}