Skip to content

Autotest delays a little bit with fsevent #33

Closed
squarism opened this Issue Sep 7, 2012 · 5 comments

2 participants

@squarism
squarism commented Sep 7, 2012

Guard executes from filesave to running the test pretty quick. Autotest initialize sets sleep=1 by default. Why is this? I looked at Activity Monitor while setting sleep to 0 and didn't see much impact. With polling, cpu is very obvious 10-20% on a core.

In my .autotest file:

# tighten up the time before the test is run
ObjectSpace.each_object(Autotest).first.sleep = 0

Which makes it run a bit like Guard. Is this terrible? I don't know what can be done. It's not a singleton, maybe Autotest should be? Maybe nothing needs to be changed but just documenting the workaround.

*** LOCAL GEMS ***
autotest-fsevent (0.2.8)
autotest-rails-pure (4.1.2)
autotest-standalone (4.5.9)

@grosser
Owner
grosser commented Sep 7, 2012

first I'd say go pick another testing tool, autotest is pretty old and pretty bad,

I think you might be able to just do a self.sleep = 0 in your .autotest, since the extensions are loaded in the autotest object
https://github.com/grosser/autotest/blob/master/lib/autotest.rb#L307

@squarism
squarism commented Sep 8, 2012

I usually use guard but one project I'm on uses Minitest which won't work with spork and guard. Autotest works and the above fix does work. self.sleep=0 doesn't work within the reopened .autotest class nor outside it.

I'll just post my .autotest file in case it helps someone. It works, I just hate how hacky it is. I wish I could get to the instance of autotest better or catch the init in a Rails initializer?

require 'autotest/fsevent'

class Autotest
  # does not work
  # self.sleep = 0

  # run tests over drb server (spork)
  def make_test_cmd files_to_test
    if files_to_test.empty?
      "" # no tests to run
    else
      "testdrb #{files_to_test.keys.join(' ')}"
    end
  end
end

# tighten up the time before the test is run
ObjectSpace.each_object(Autotest).first.sleep = 0

# does not work
#self.sleep = 0
@squarism squarism closed this Sep 8, 2012
@grosser
Owner
grosser commented Sep 8, 2012

Looks like load has no access to the current scope (not event instance vars)
it's a weird spot since autotest is already initialized + you do not get access to the instance.
A way would be to have Autotest.sleep and when sleeping do sleep sleep || self.class.sleep so you could overwrite it.
I'd merge a pull for this if you care enough to build it :)

@squarism

I'll work on it then. :)

Issue #34 pull request opened for this.

@squarism squarism reopened this Sep 12, 2012
@squarism squarism closed this Oct 15, 2012
@squarism squarism reopened this Oct 15, 2012
@squarism

❤️

@squarism squarism closed this Oct 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.