Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ Added autotest -w flag to turn on warnings. Turned off warnings by …

…default.

+ Added child process handling/cleanup on signals.
+ Added autotest/preload.rb to deal with rails being egregiously slow.
[git-p4: depot-paths = "//src/ZenTest/dev/": change = 6100]
  • Loading branch information...
commit 48bc5b0f582aaf769754a1396cc6cba88d014cb0 1 parent 64c6ec2
@zenspider zenspider authored
View
1  Manifest.txt
@@ -21,6 +21,7 @@ lib/autotest/autoupdate.rb
lib/autotest/bundler.rb
lib/autotest/isolate.rb
lib/autotest/once.rb
+lib/autotest/preload.rb
lib/autotest/rcov.rb
lib/autotest/restart.rb
lib/autotest/timestamp.rb
View
1  bin/autotest
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
-$-w = true
require 'autotest'
View
10 lib/autotest.rb
@@ -125,6 +125,10 @@ def self.parse_options args = ARGV
options[:style] = Array(style)
end
+ opts.on("-w", "--warnings", "Turn on ruby warnings") do
+ $-w = true
+ end
+
opts.on "-h", "--help", "Show this." do
puts opts
exit 1
@@ -268,6 +272,7 @@ def initialize
# add/remove/clear accessor methods
@exception_list = []
@test_mappings = []
+ @child = nil
self.completed_re =
/\d+ tests, \d+ assertions, \d+ failures, \d+ errors(, \d+ skips)?/
@@ -314,7 +319,6 @@ def run
hook :initialize
reset
add_sigint_handler
- add_sigquit_handler
self.last_mtime = Time.now if options[:no_full_after_start]
@@ -403,6 +407,8 @@ def run_tests
def add_sigint_handler
trap 'INT' do
+ Process.kill "KILL", @child if @child
+
if self.interrupted then
self.wants_to_quit = true
else
@@ -426,6 +432,8 @@ def add_sigquit_handler
end
def restart
+ Process.kill "KILL", @child if @child
+
cmd = [$0, *ARGV]
index = $LOAD_PATH.index RbConfig::CONFIG["sitelibdir"]
View
46 lib/autotest/preload.rb
@@ -0,0 +1,46 @@
+module Autotest::Restart
+ Autotest.add_hook :initialize do |at, *args|
+ at.add_sigquit_handler
+
+ warn "pre-loading initializers"
+ t0 = Time.now
+ Dir['{test,spec}/*{test,spec}_helper.rb'].each do |path|
+ require path
+ end
+ warn "done pre-loading initializers in %.2f seconds" % [Time.now - t0]
+
+ false
+ end
+end
+
+class Autotest
+ alias :old_run_tests :run_tests
+
+ def run_tests
+ hook :run_command
+
+ new_mtime = self.find_files_to_test
+ return unless new_mtime
+ self.last_mtime = new_mtime
+
+ begin
+ # TODO: deal with unit_diff and partial test runs later
+ original_argv = ARGV.dup
+ ARGV.clear
+
+ @child = fork do
+ trap "QUIT", "DEFAULT"
+ trap "INT", "DEFAULT"
+ files_to_test.keys.each do |file|
+ load file
+ end
+ end
+ Process.wait
+ ensure
+ @child = nil
+ ARGV.replace original_argv
+ end
+
+ hook :ran_command
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.