#!/usr/bin/ruby

$LOAD_PATH.push(File.expand_path('lib'))

require 'ruby_test'
require 'optparse'

module RubyTest
  VERSION = '0.1.0'
  def self.run(file)
    puts("The process may have returned a non-zero exit status: #{$?}") unless system("ruby test/#{file}")
  end
end

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: ruby-test [options]"

  opts.on("-v", "--version", "Print version.") { |v| options[:version] = v }
  opts.on("-r", "--run", "Run every test in test directory.") { |r| options[:run] = r }
end.parse!

puts(RubyTest::VERSION) if options[:version]

if options[:run]
  entries = Dir.entries('test')
  entries.delete('.')
  entries.delete('..')
  entries.each { |entry| RubyTest.run(entry) }
end
