ewollesen / autotest-inotify

Teaches autotest to use inotify (on Linux) instead of filesystem polling.
http://kill-0.com/projects/autotest-inotify
MIT License
18 stars 7 forks source link

error loading failed test #4

Open ghost opened 14 years ago

ghost commented 14 years ago

I encountered a strange bug in autotest-inotify and managed to fix it for me. However, my fix looks a bit dirty and so I'll explain the problem:

When running a test with autotest-inotify, everything works fine, until a test failure or error appears. After fixing the failing test, autotests standard behaviour is to run the test and if it passes, reset and run all tests.

However, with autotest-inotify, the "run all tests" step at the end isn't done. The result is, that @known_files is empty and autotest-inotify doesn't find any further tests to run.

My fix included two changes in find_files_to_test(files=nil):

  def find_files_to_test(files=nil)
    if first_time_run?
      setup_inotify
      unless options[:no_full_after_start]
        select_all_tests
      end
    else
      if self.last_mtime.to_i == 0
        @changed_files = find_files
        hook :updated, @changed_files
        select_all_tests
      else
        p @changed_files if $v
        order = []
        @changed_files.each_key {|key| order << key }
        hook :updated, @changed_files
        self.find_order.push(*order.sort)
        select_tests_for_changed_files
      end
    end
    return Time.now
  end

I inserted the if self.last_mtime.to_i == 0 block to check if a reset happened (which means run all tests) and I added the self.find_order.push(*order.sort) because this is where @known_files gets filled.

sigi commented 14 years ago

I can confirm this bug. Forcing the entire suit to run by interrupting (^C) does not work either anymore.

The changes shown above fix both problems for me.

ewollesen commented 14 years ago

Sorry for the long delay in getting back to you. Could you please fork, and make a pull request? That way the changes will be logged with your name (so credit goes where credit is due)

t-mart commented 13 years ago

Changes fixed me too.

mschulkind commented 13 years ago

Did this ever get fixed in master? I'm having what appears to be the same issue and I'm not entirely sure how to apply this fix since the code looks different now.

ghost commented 13 years ago

I did no further work on this and I'm completely out of ruby, rails etc. right now, so I hope, somebody else can pick this thread up.

ghost commented 13 years ago

sorry, I didn't want to close the thread