$LOAD_PATH << File.expand_path("lib/")
$LOAD_PATH << File.expand_path("test/")

EXPANDED_LOAD_PATH=$LOAD_PATH.map { |d| File.expand_path d }
EXCLUDED_TESTS = Dir["test/gsl/nmatrix_tests/*.rb"]

oldpath = Dir.getwd
(Dir["test/**/*.rb"] - EXCLUDED_TESTS).each do |f|
  puts "*** running #{f} ***"
  dir, filename = File.split f
  begin
    Dir.chdir File.expand_path(dir)
    system("#{ENV['RUBY_TEST_BIN']} -I#{EXPANDED_LOAD_PATH.join(":")} #{filename}") || exit($?.exitstatus)
  ensure
    Dir.chdir oldpath
  end
end
