<commit_before>require 'spec_helper'

describe Looksee::WirbleCompatibility do
  describe "when looksee is loaded" do
    #
    # Run the given ruby string, and return the standard output.
    #
    def init_irb_with(code)
      code = <<-EOS.demargin
        |#{code}
        |#{setup_code}
        |c.ls
      EOS
      code = code.chomp.gsub(/\n/, ';') # only print value of last line
      irb = File.join Config::CONFIG['bindir'], 'irb'
      lib_dir = File.expand_path('lib')
      # irb hangs when using readline without a tty
      output = IO.popen("bundle exec #{irb} -f --noreadline --noprompt --noverbose -I#{lib_dir} 2>&1", 'r+') do |io|
        io.puts code
        io.flush
        io.close_write
        io.read
      end
      # Ruby 1.9.2 prints an extra newline on exit.
      output.chomp! if RUBY_VERSION >= '1.9.2'
      output
    end<commit_msg>Handle noisy 1.9.3 GC in wirble compatibility specs.<commit_after>require 'spec_helper'

describe Looksee::WirbleCompatibility do
  describe "when looksee is loaded" do
    #
    # Run the given ruby string, and return the standard output.
    #
    def init_irb_with(code)
      code = <<-EOS.demargin
        |#{code}
        |#{setup_code}
        |c.ls
      EOS
      code = code.chomp.gsub(/\n/, ';') # only print value of last line
      irb = File.join Config::CONFIG['bindir'], 'irb'
      lib_dir = File.expand_path('lib')
      # irb hangs when using readline without a tty
      output = IO.popen("bundle exec #{irb} -f --noreadline --noprompt --noverbose -I#{lib_dir} 2>&1", 'r+') do |io|
        io.puts code
        io.flush
        io.close_write
        io.read
      end
      # Ruby 1.9.3 prints gc parameters if configured
      nil while output.gsub!(/^(?:malloc_limit|heap_min_slots|free_min)=.*\n/, '')
      # Ruby 1.9.2 prints an extra newline on exit.
      output.chomp! if RUBY_VERSION >= '1.9.2'
      output
    end
{'fraction_non_alphanumeric': 0.12434691745036573, 'fraction_numerical': 0.011494252873563218, 'mean_word_length': 2.279109589041096, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5695841', 'n_tokens_mistral': 672, 'n_tokens_neox': 657, 'n_words': 184}