Permalink
Browse files

ADDED: -q option for reduced output.

  • Loading branch information...
1 parent 0cf3596 commit 79dd46c5e1c3b1031833f99e3fb4e61c6858c76f @delano committed Jan 6, 2011
Showing with 28 additions and 9 deletions.
  1. +4 −0 CHANGES.txt
  2. +1 −1 VERSION.yml
  3. +14 −0 bin/try
  4. +9 −8 lib/tryouts.rb
View
@@ -1,5 +1,9 @@
TRYOUTS, CHANGES
+#### 2.0.4 (2011-01-06) ###############################
+
+* ADDED: -q option for reduced output.
+
#### 2.0.3 (2010-11-03) ###############################
* FIXED: Print test value not expected value twice!
View
@@ -1,5 +1,5 @@
---
:MAJOR: 2
:MINOR: 0
-:PATCH: 3
+:PATCH: 4
:BUILD: '001'
View
@@ -1,5 +1,16 @@
#!/usr/bin/ruby
+#
+# Tryouts - Don't waste your time writing tests
+#
+# Usage:
+#
+# $ try
+# $ try -q
+# $ try path/2/file.rb
+# $ try -q path/2/file.rb path/2/another.rb
+#
+
# Put our local lib in first place
BASE_PATH = File.expand_path File.join(File.dirname(__FILE__), '..')
lib_dir = File.join(BASE_PATH, 'lib')
@@ -12,13 +23,16 @@ require 'tryouts'
$:.unshift dir
end
+Tryouts.quiet = !ARGV.delete('-q').nil? # eg try -q [PATH]
+
if ARGV.empty?
paths = Dir.glob(File.join(Dir.pwd, '{try,tryouts}', '*_{try,tryouts}.rb'))
paths += Dir.glob(File.join(Dir.pwd, '*_{try,tryouts}.rb'))
else
paths = ARGV
end
+#Tryouts.quiet
#Tryouts.debug = true
#Tryouts.container = self
View
@@ -26,11 +26,12 @@ def self.load_config
class Tryouts
@debug = false
+ @quiet = false
@container = Class.new
@cases = []
@sysinfo = nil
class << self
- attr_accessor :debug, :container
+ attr_accessor :debug, :container, :quiet
attr_reader :cases
def sysinfo
@@ -55,30 +56,30 @@ def run_all *paths
path = batch.path.gsub(/#{Dir.pwd}\/?/, '')
- msg '%-60s %s' % [path, ''] # status
+ msg '%-60s %s' % [path, ''] unless Tryouts.quiet # status
before_handler = Proc.new do |t|
- msg Console.reverse(' %-58s ' % [t.desc.to_s])
- msg t.test.inspect, t.exps.inspect
+ msg Console.reverse(' %-58s ' % [t.desc.to_s]) unless Tryouts.quiet
+ msg t.test.inspect, t.exps.inspect unless Tryouts.quiet
end
batch.run(before_handler) do |t|
if t.failed?
failed_tests += 1
- msg Console.color(:red, t.failed.join($/)), $/
+ msg Console.color(:red, t.failed.join($/)), $/ unless Tryouts.quiet
elsif t.skipped? || !t.run?
skipped_tests += 1
- msg Console.bright(t.skipped.join($/)), $/
+ msg Console.bright(t.skipped.join($/)), $/ unless Tryouts.quiet
else
- msg Console.color(:green, t.passed.join($/)), $/
+ msg Console.color(:green, t.passed.join($/)), $/ unless Tryouts.quiet
end
all += 1
end
end
- msg
+ msg unless Tryouts.quiet
if all > 0
suffix = 'tests passed'
suffix << " (and #{skipped_tests} skipped)" if skipped_tests > 0

0 comments on commit 79dd46c

Please sign in to comment.