Permalink
Browse files

ADDED: -v option for increased output.

  • Loading branch information...
1 parent b0a2968 commit 40fa2d5d5f8937baf36be72bf02612dd5c0f1c2d @delano committed Feb 12, 2011
Showing with 28 additions and 15 deletions.
  1. +5 −0 CHANGES.txt
  2. +1 −1 Rakefile
  3. +0 −1 VERSION.yml
  4. +7 −0 bin/try
  5. +15 −13 lib/tryouts.rb
View
5 CHANGES.txt
@@ -1,5 +1,10 @@
TRYOUTS, CHANGES
+#### 2.1.0 (2011-02-12) ###############################
+
+* ADDED: -v option for increased output.
+
+
#### 2.0.4 (2011-01-06) ###############################
* ADDED: -q option for reduced output.
View
2 Rakefile
@@ -33,7 +33,7 @@ end
Rake::RDocTask.new do |rdoc|
- version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}.#{config[:BUILD]}"
+ version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}}"
rdoc.rdoc_dir = "doc"
rdoc.title = "stella #{version}"
rdoc.rdoc_files.include("README*")
View
1 VERSION.yml
@@ -2,4 +2,3 @@
:MAJOR: 2
:MINOR: 0
:PATCH: 4
-:BUILD: '001'
View
7 bin/try
@@ -7,6 +7,7 @@
#
# $ try
# $ try -q
+# $ try -v
# $ try path/2/file.rb
# $ try -q path/2/file.rb path/2/another.rb
#
@@ -23,7 +24,13 @@ require 'tryouts'
$:.unshift dir
end
+unless ARGV.delete('-V').nil?
+ puts "Tryouts: #{Tryouts::VERSION}"
+ exit
+end
+
Tryouts.quiet = !ARGV.delete('-q').nil? # eg try -q [PATH]
+Tryouts.noisy = !ARGV.delete('-v').nil? # eg try -v [PATH]
if ARGV.empty?
paths = Dir.glob(File.join(Dir.pwd, '{try,tryouts}', '*_{try,tryouts}.rb'))
View
28 lib/tryouts.rb
@@ -12,10 +12,7 @@ def self.to_s
load_config
[@version[:MAJOR], @version[:MINOR], @version[:PATCH]].join('.')
end
- def self.inspect
- load_config
- [@version[:MAJOR], @version[:MINOR], @version[:PATCH], @version[:BUILD]].join('.')
- end
+ alias_method :inspect, :to_s
def self.load_config
require 'yaml'
@version ||= YAML.load_file(File.join(TRYOUTS_LIB_HOME, '..', 'VERSION.yml'))
@@ -27,11 +24,12 @@ def self.load_config
class Tryouts
@debug = false
@quiet = false
+ @noisy = false
@container = Class.new
@cases = []
@sysinfo = nil
class << self
- attr_accessor :debug, :container, :quiet
+ attr_accessor :debug, :container, :quiet, :noisy
attr_reader :cases
def sysinfo
@@ -56,30 +54,30 @@ def run_all *paths
path = batch.path.gsub(/#{Dir.pwd}\/?/, '')
- msg '%-60s %s' % [path, ''] unless Tryouts.quiet # status
+ vmsg '%-60s %s' % [path, '']
before_handler = Proc.new do |t|
- msg Console.reverse(' %-58s ' % [t.desc.to_s]) unless Tryouts.quiet
- msg t.test.inspect, t.exps.inspect unless Tryouts.quiet
+ vmsg Console.reverse(' %-58s ' % [t.desc.to_s])
+ vmsg t.test.inspect, t.exps.inspect
end
batch.run(before_handler) do |t|
if t.failed?
failed_tests += 1
- msg Console.color(:red, t.failed.join($/)), $/ unless Tryouts.quiet
+ vmsg Console.color(:red, t.failed.join($/)), $/
elsif t.skipped? || !t.run?
skipped_tests += 1
- msg Console.bright(t.skipped.join($/)), $/ unless Tryouts.quiet
+ vmsg Console.bright(t.skipped.join($/)), $/
else
- msg Console.color(:green, t.passed.join($/)), $/ unless Tryouts.quiet
+ vmsg Console.color(:green, t.passed.join($/)), $/
end
all += 1
end
end
- msg unless Tryouts.quiet
+ vmsg
if all > 0
suffix = 'tests passed'
suffix << " (and #{skipped_tests} skipped)" if skipped_tests > 0
@@ -179,8 +177,12 @@ def print str
STDOUT.flush
end
+ def vmsg *msg
+ STDOUT.puts *msg if !Tryouts.quiet && Tryouts.noisy
+ end
+
def msg *msg
- STDOUT.puts *msg
+ STDOUT.puts *msg unless Tryouts.quiet
end
def err *msg

0 comments on commit 40fa2d5

Please sign in to comment.