<commit_before>#!/usr/bin/env ruby

GREEN = "\033[32m"
RED = "\033[31m"
RESET = "\033[0m"

def read_tests test_case
  Dir.glob("#{test_case}/*.in").collect do |input_file|
    name = input_file[(test_case.length + 1)...(input_file.length - 3)]
    input = IO.read(input_file).strip

    output_files = Dir.glob "#{test_case}/#{name}.out*"
    potential_outputs = output_files.collect do |output_file|
      IO.read(output_file).strip.inspect
    end

    [name, input, potential_outputs]
  end
end

def run_tests tests, application
  tests.each do |name, input, potential_outputs|
    puts name
    next failed "no outputs provided" if potential_outputs.length == 0

    output = IO.popen application, 'r+' do |io|
      io.write input
      io.close_write
      io.read.strip.inspect
    end

    unless potential_outputs.include? output
      if potential_outputs.length == 1
        next failed "output:   #{output}", "expected: #{potential_outputs[0]}"
      end

      next failed "output:   #{output}", "expected: #{potential_outputs[0...potential_outputs.length - 1].join(', ')} or #{potential_outputs[-1]}"
    end

    succeeded 'succeeded'
  end
end
<commit_msg>Shows the test input for failures.<commit_after>#!/usr/bin/env ruby

GREEN = "\033[32m"
RED = "\033[31m"
RESET = "\033[0m"

def read_tests test_case
  Dir.glob("#{test_case}/*.in").collect do |input_file|
    name = input_file[(test_case.length + 1)...(input_file.length - 3)]
    input = IO.read(input_file).strip

    output_files = Dir.glob "#{test_case}/#{name}.out*"
    potential_outputs = output_files.collect do |output_file|
      IO.read(output_file).strip.inspect
    end

    [name, input, potential_outputs]
  end
end

def run_tests tests, application
  tests.each do |name, input, potential_outputs|
    puts name
    next failed "no outputs provided" if potential_outputs.length == 0

    output = IO.popen application, 'r+' do |io|
      io.write input
      io.close_write
      io.read.strip.inspect
    end

    unless potential_outputs.include? output
      if potential_outputs.length == 1
        next failed "input:    #{input.inspect}", "output:   #{output}", "expected: #{potential_outputs[0]}"
      end

      next failed "input:    #{input.inspect}", "output:   #{output}", "expected: #{potential_outputs[0...potential_outputs.length - 1].join(', ')} or #{potential_outputs[-1]}"
    end

    succeeded 'succeeded'
  end
end

{'fraction_non_alphanumeric': 0.13896907216494844, 'fraction_numerical': 0.018144329896907216, 'mean_word_length': 3.3398926654740606, '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': '7258296', 'n_tokens_mistral': 835, 'n_tokens_neox': 792, 'n_words': 191}