Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I troubleshoot autotest infinite loop problems?

I'm using cucumber, rails3, rspec2 and autotest. I'm trying to figure out why my features are infinitely looping. I suspect it some file being changed during the tests but I'm not sure which one. I've added some exceptions to my .autotest with no dice.

Are there any steps I can take to troubleshoot this problem?

It'd be cool if I could see what files are triggering a rerun or, at run time, what files are being watched/not watched.

here's my .autotest contents

require 'autotest/growl'

Autotest::Growl::clear_terminal = false

# Skip some paths
Autotest.add_hook :initialize do |autotest|
    %w{.git .DS_store db log tmp rerun.txt}.each { |e| autotest.add_exception(e) }
end
like image 537
Dane O'Connor Avatar asked Jul 06 '10 21:07

Dane O'Connor


4 Answers

Ok, so I figured it out. I dove into autotest's source to get a better understanding of what was going on. It creates a Regexp.union out of all the exceptions and ignores files who's relative paths match the complied expression.

To better understand the bug I added everything in my project's directory to .autotest except ./app, ./lib, ./public, ./script, ./spec and ./features. Something like this:

# .autotest - to troubleshoot
Autotest.add_hook :initialize do |at|
  at.add_exception(%r{^\./\.git})
  ...
  at.add_exception(%r{^\./db})
  ...
  at.add_exception(%r{^\./rerun.txt})
  ...
end

When I did this I didn't get an infinite loop. After that I just began to comment out each exception. Turns out, the only file I had to manually ignore was Gemfile.lock. For some reason this is either being changed or confusing autotest to the point where it makes cucumber loop.

Thus, this .autotest solved the problem:

# .autotest - to fix
Autotest.add_hook :initialize do |at|
  # Gemfile.lock is causing cucumber to run infinitely. Don't watch it.
  at.add_exception(%r{^\./Gemfile.lock})
end

I'm going to report on the cucumber list to let them know they should add that to the built in autotest exceptions.

like image 57
Dane O'Connor Avatar answered Nov 18 '22 21:11

Dane O'Connor


Just wanted to say thanks. Turns out, for me, it was the log directory. My .autotest file looks like this.

# .autotest
Autotest.add_hook :initialize do |at|
  # Log directory is causing cucumber to run infinitely.
  at.add_exception(%r{^\./log})
end

For reference, see "Customizing Autotest Behavior" in http://github.com/aslakhellesoy/cucumber/wiki/Autotest-Integration, which talks about the infinite loop problem.

like image 31
Harry Love Avatar answered Nov 18 '22 21:11

Harry Love


In Linux/Unix you can use the command:

$ find . -mmin -5

to figure out which files were modified in the last 5 minutes (or whatever lapse is appropiate). This can greatly help in finding the file which is triggering infinite loop. Then add the exception as explained in the other answers.

In my case, the culprit was webrat.log.

like image 6
Gustavo Giráldez Avatar answered Nov 18 '22 21:11

Gustavo Giráldez


It's worth noting that you can pass -v to autospec/autotest and it will print out what triggered it to run.

like image 5
Jared Avatar answered Nov 18 '22 22:11

Jared