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

EXPANDED_LOAD_PATH=$LOAD_PATH.map { |d| File.expand_path d }
EXCLUDED_TESTS=["tests/sf/make_test.rb",
                "tests/speed/bench.rb",
                "tests/tensor.rb"
               ]

oldpath = Dir.getwd
(Dir["tests/**/*.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
