<commit_before># frozen_string_literal: true

require_relative '../lib/rmk.rb'

class PlanMock
  def md5
    'md5'
  end

  def build_dir
    '/tmp/rmk'
  end

  def dir
    '/tmp/rmk'
  end
end

PLAN = PlanMock.new
describe Rmk::Job, '#relative_path_from' do
  around(:each) do |example|
    example.run
    FileUtils.rm_rf(PLAN.build_dir)
  end

  it 'propagate exceptions' do<commit_msg>First test for jobs<commit_after># frozen_string_literal: true

require_relative '../lib/rmk.rb'

class PlanMock
  def md5
    'md5'
  end

  def build_dir
    '/tmp/rmk'
  end

  def dir
    '/tmp/rmk'
  end
end

PLAN = PlanMock.new
describe Rmk::Job do
  around(:each) do |example|
    example.run
    FileUtils.rm_rf(PLAN.build_dir)
  end

  it 'handle exceptions correct' do
    plan = PlanMock.new

    job = Rmk::Job.new('job1', PLAN, []) do
      raise StandardError, 'test'
    end

    # start build
    job.build(Rmk::ModificationTimeBuildPolicy.new)
    expect(job.exception).not_to be_nil
    expect { job.result }.to raise_error(StandardError)
  end

  it 'propagate exceptions' do
{'fraction_non_alphanumeric': 0.1070110701107011, 'fraction_numerical': 0.004612546125461255, 'mean_word_length': 3.048507462686567, 'pattern_counts': {'":': 0, '<': 3, '<?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': '878845', 'n_tokens_mistral': 412, 'n_tokens_neox': 398, 'n_words': 98}