lib/tryouts.rb in tryouts-2.2.0 vs lib/tryouts.rb in tryouts-2.3.0

- old
+ new

@@ -2,34 +2,22 @@ unless defined?(TRYOUTS_LIB_HOME) TRYOUTS_LIB_HOME = File.expand_path File.dirname(__FILE__) end -class Tryouts - module VERSION - def self.to_s - load_config - [@version[:MAJOR], @version[:MINOR], @version[:PATCH]].join('.') - end - alias_method :inspect, :to_s - def self.load_config - require 'yaml' - @version ||= YAML.load_file(File.join(TRYOUTS_LIB_HOME, '..', 'VERSION.yml')) - end - end -end +require_relative 'tryouts/version' - class Tryouts @debug = false @quiet = false @noisy = false + @fails = false @container = Class.new @cases = [] @sysinfo = nil class << self - attr_accessor :debug, :container, :quiet, :noisy + attr_accessor :debug, :container, :quiet, :noisy, :fails attr_reader :cases def sysinfo require 'sysinfo' @sysinfo ||= SysInfo.new @@ -46,38 +34,44 @@ all, skipped_tests, failed_tests = 0, 0, 0 skipped_batches, failed_batches = 0, 0 msg 'Ruby %s @ %-40s' % [RUBY_VERSION, Time.now], $/ + if Tryouts.debug? + Tryouts.debug "Found #{paths.size} files:" + paths.each { |path| Tryouts.debug " #{path}" } + Tryouts.debug + end + batches.each do |batch| path = batch.path.gsub(/#{Dir.pwd}\/?/, '') vmsg '%-60s %s' % [path, ''] before_handler = Proc.new do |t| - if Tryouts.noisy + if Tryouts.noisy && !Tryouts.fails vmsg Console.reverse(' %-58s ' % [t.desc.to_s]) vmsg t.test.inspect, t.exps.inspect end end batch.run(before_handler) do |t| if t.failed? failed_tests += 1 - if Tryouts.noisy + if Tryouts.noisy && Tryouts.fails vmsg Console.color(:red, t.failed.join($/)), $/ else msg ' %s (%s:%s)' % [Console.color(:red, "FAIL"), path, t.exps.first] end - elsif t.skipped? || !t.run? + elsif (t.skipped? || !t.run?) && !Tryouts.fails skipped_tests += 1 if Tryouts.noisy vmsg Console.bright(t.skipped.join($/)), $/ else msg ' SKIP (%s:%s)' % [path, t.exps.first] end - else + elsif !Tryouts.fails if Tryouts.noisy vmsg Console.color(:green, t.passed.join($/)), $/ else msg ' %s' % [Console.color(:green, 'PASS')] end