Created
March 6, 2010 22:30
-
-
Save joakimk/323985 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .autotest in your project or ~/.autotest | |
# This reduces the time from when you save a file to when autotest runs the tests. | |
# Optimization: Quicker response time for the files you change more than once | |
class Autotest | |
alias_method :find_files_orig, :find_files | |
def find_files | |
result = {} | |
@recently_updated ||= [] | |
@recently_updated.each do |file| | |
result[file] = File.stat(file).mtime rescue nil | |
return result if result[file] && self.last_mtime < result[file] | |
end | |
find_files_orig | |
end | |
alias_method :find_files_to_test_orig, :find_files_to_test | |
def find_files_to_test(files = find_files) | |
@recently_updated ||= [] | |
updated = files.select { |filename, mtime| self.last_mtime < mtime } | |
updated.each do |file| | |
@recently_updated << file.first unless @recently_updated.include?(file.first) | |
end | |
find_files_to_test_orig(files) | |
end | |
end | |
Autotest.add_hook :initialize do |at| | |
# Makes change detection much faster (but CPU usage higher) | |
at.sleep = 0.1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment