Skip to content
Browse files

Command line options (-T) for timeouts on testing

[git-p4: depot-paths = "//src/heckle/dev/": change = 2878]
  • Loading branch information...
1 parent 9b1f0e2 commit 88afdf2fe2de98b7d35fab13e30d1d5f354cc34b @kevinclark kevinclark committed Jan 11, 2007
Showing with 20 additions and 8 deletions.
  1. +0 −2 Manifest.txt
  2. +6 −0 bin/heckle
  3. +6 −0 lib/heckle.rb
  4. +8 −6 lib/test_unit_heckler.rb
View
2 Manifest.txt
@@ -4,8 +4,6 @@ README.txt
Rakefile
bin/heckle
lib/heckle.rb
-lib/heckle/base.rb
-lib/heckle/reporter.rb
lib/test_unit_heckler.rb
sample/Rakefile
sample/changes.log
View
6 bin/heckle
@@ -23,6 +23,12 @@ opts = OptionParser.new do |opts|
Heckle::MUTATABLE_NODES.replace [:if, :while, :until]
end
+
+ opts.on( "-T", "--timeout SECONDS", "The maximum time for a test run in seconds",
+ "Used to catch infinite loops") do |timeout|
+ Heckle.timeout = timeout.to_i
+ puts "Setting timeout at #{timeout} seconds."
+ end
opts.on( "-h", "--help", "Show this message") do |opt|
puts opts
View
6 lib/heckle.rb
@@ -20,6 +20,7 @@ class Heckle < SexpProcessor
:failures, :count)
@@debug = false
+ @@guess_timeout = true
@@timeout = 60 # default to something longer (can be overridden by runners)
def self.debug=(value)
@@ -28,6 +29,11 @@ def self.debug=(value)
def self.timeout=(value)
@@timeout = value
+ @@guess_timeout = false # We've set the timeout, don't guess
+ end
+
+ def self.guess_timeout?
+ @@guess_timeout
end
def initialize(klass_name=nil, method_name=nil, reporter = Reporter.new)
View
14 lib/test_unit_heckler.rb
@@ -25,15 +25,17 @@ def self.validate(klass_name, method_name = nil)
unless self.new(klass_name).tests_pass? then
abort "Initial run of tests failed... fix and run heckle again"
end
- running_time = (Time.now - initial_time)
- adjusted_timeout = (running_time * 2 < 5) ? 5 : (running_time * 2)
- self.timeout = adjusted_timeout
+
+ if self.guess_timeout?
+ running_time = (Time.now - initial_time)
+ adjusted_timeout = (running_time * 2 < 5) ? 5 : (running_time * 2)
+ self.timeout = adjusted_timeout
+ puts "Setting timeout at #{adjusted_timeout} seconds." if @@debug
+
+ end
puts "Initial tests pass. Let's rumble."
- puts "Setting timeout at #{adjusted_timeout} seconds." if @@debug
-
-
methods = method_name ? Array(method_name) : klass.instance_methods(false)
methods.each do |method_name|

0 comments on commit 88afdf2

Please sign in to comment.
Something went wrong with that request. Please try again.