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

$KCODE = 'utf-8' unless defined?(Encoding)

require 'rbconfig'
require 'fileutils'

build_dir = File.expand_path(ENV["BUILD_DIR"] || File.dirname(__FILE__))
base_dir = File.expand_path(ENV["BASE_DIR"] || File.dirname(__FILE__))

test_lib_dir = File.expand_path(File.join(build_dir, "..", "lib"))
FileUtils.mkdir_p(test_lib_dir)

test_unit_dir = File.join(test_lib_dir, "test-unit-2.0.9")
unless File.exist?(test_unit_dir)
  require "open-uri"
  tgz_uri = "http://rubyforge.org/frs/download.php/70989/test-unit-2.0.9.tgz"
  tgz = File.join(build_dir, File.basename(tgz_uri))
  File.open(tgz, "wb") do |output|
    output.print(open(tgz_uri).read)
  end
  system("tar", "xfz", tgz, "-C", test_lib_dir)
end

$LOAD_PATH.unshift(File.join(test_unit_dir, "lib"))

require 'test/unit'
require 'test/unit/version'

if Test::Unit::VERSION < "2.1.0"
  module Test::Unit::Assertions
    def assert_path_exist(path, message=nil)
      _wrap_assertion do
        failure_message = build_message(message,
                                        "<?> expected to exist",
                                        path)
        assert_block(failure_message) do
          File.exist?(path)
        end
      end
    end

    def assert_path_not_exist(path, message=nil)
      _wrap_assertion do
        failure_message = build_message(message,
                                        "<?> expected to not exist",
                                        path)
        assert_block(failure_message) do
          not File.exist?(path)
        end
      end
    end
  end
end

json_dir = File.join(test_lib_dir, "json-1.1.9")
unless File.exist?(json_dir)
  require "open-uri"
  require "fileutils"
  tgz_uri = "http://rubyforge.org/frs/download.php/62984/json-1.1.9.tgz"
  tgz = File.join(build_dir, File.basename(tgz_uri))
  File.open(tgz, "wb") do |output|
    output.print(open(tgz_uri).read)
  end
  system("tar", "xfz", tgz, "-C", test_lib_dir)
  ext_parser_dir = File.join(json_dir, "ext", "json", "ext", "parser")
  Dir.chdir(ext_parser_dir) do
    ruby = File.join(RbConfig::CONFIG["bindir"],
                     RbConfig::CONFIG["ruby_install_name"])
    system(ruby, "extconf.rb")
    system("make")
  end
  FileUtils.mv(File.join(ext_parser_dir, "parser.so"),
               File.join(json_dir, "lib", "json", "ext"))
end
$LOAD_PATH.unshift(File.join(json_dir, "lib"))


$LOAD_PATH.unshift(File.join(base_dir, "lib", "ruby"))

require 'groonga-test-utils'
require 'groonga-http-test-utils'
require 'groonga-local-gqtp-test-utils'

ARGV.unshift("--exclude", "run-test.rb")
exit Test::Unit::AutoRunner.run(true, File.dirname($0))<commit_msg>update test-unit version and use test-unit-notify.<commit_after>#!/usr/bin/env ruby

$KCODE = 'utf-8' unless defined?(Encoding)

require 'rbconfig'
require 'fileutils'

build_dir = File.expand_path(ENV["BUILD_DIR"] || File.dirname(__FILE__))
base_dir = File.expand_path(ENV["BASE_DIR"] || File.dirname(__FILE__))

test_lib_dir = File.expand_path(File.join(build_dir, "..", "lib"))
FileUtils.mkdir_p(test_lib_dir)

test_unit_dir = File.join(test_lib_dir, "test-unit-2.1.1")
unless File.exist?(test_unit_dir)
  require "open-uri"
  tgz_uri = "http://rubyforge.org/frs/download.php/71835/test-unit-2.1.1.tgz"
  tgz = File.join(build_dir, File.basename(tgz_uri))
  File.open(tgz, "wb") do |output|
    output.print(open(tgz_uri).read)
  end
  system("tar", "xfz", tgz, "-C", test_lib_dir)
end
$LOAD_PATH.unshift(File.join(test_unit_dir, "lib"))

test_unit_notify_dir = File.join(test_lib_dir, "test-unit-notify-0.0.1")
unless File.exist?(test_unit_notify_dir)
  require "open-uri"
  tgz_uri = "http://rubyforge.org/frs/download.php/71705/test-unit-notify-0.0.1.tgz"
  tgz = File.join(build_dir, File.basename(tgz_uri))
  File.open(tgz, "wb") do |output|
    output.print(open(tgz_uri).read)
  end
  system("tar", "xfz", tgz, "-C", test_lib_dir)
end
$LOAD_PATH.unshift(File.join(test_unit_notify_dir, "lib"))

require 'test/unit'
require 'test/unit/version'
require 'test/unit/notify'

json_dir = File.join(test_lib_dir, "json-1.1.9")
unless File.exist?(json_dir)
  require "open-uri"
  require "fileutils"
  tgz_uri = "http://rubyforge.org/frs/download.php/62984/json-1.1.9.tgz"
  tgz = File.join(build_dir, File.basename(tgz_uri))
  File.open(tgz, "wb") do |output|
    output.print(open(tgz_uri).read)
  end
  system("tar", "xfz", tgz, "-C", test_lib_dir)
  ext_parser_dir = File.join(json_dir, "ext", "json", "ext", "parser")
  Dir.chdir(ext_parser_dir) do
    ruby = File.join(RbConfig::CONFIG["bindir"],
                     RbConfig::CONFIG["ruby_install_name"])
    system(ruby, "extconf.rb")
    system("make")
  end
  FileUtils.mv(File.join(ext_parser_dir, "parser.so"),
               File.join(json_dir, "lib", "json", "ext"))
end
$LOAD_PATH.unshift(File.join(json_dir, "lib"))


$LOAD_PATH.unshift(File.join(base_dir, "lib", "ruby"))

require 'groonga-test-utils'
require 'groonga-http-test-utils'
require 'groonga-local-gqtp-test-utils'

ARGV.unshift("--exclude", "run-test.rb")
ARGV.unshift("--notify")
exit Test::Unit::AutoRunner.run(true, File.dirname($0))
{'fraction_non_alphanumeric': 0.16640685892439594, 'fraction_numerical': 0.012081060015588464, 'mean_word_length': 3.801683816651076, 'pattern_counts': {'":': 0, '<': 6, '<?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': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5793287', 'n_tokens_mistral': 2003, 'n_tokens_neox': 1928, 'n_words': 302}