doo icon indicating copy to clipboard operation
doo copied to clipboard

Debounce test running?

Open magnars opened this issue 8 years ago • 4 comments

Hi!

Thanks a lot for doo - finally a test runner for cljs that works great. :)

One of the things I really love with doo is how fast it re-runs my tests after a save. However, it is so excellent in this, that if you perform many file changes at once (eg with "save all" or when changing branches), doo will run all the tests many times - once for each change.

Maybe the test runner could have a soft debounce (50ms?) to gather up all the changes and run the tests once in this case?

magnars avatar May 31 '16 07:05 magnars

Hi @magnars,

That sounds like a great idea. Do you know of any other tools that implement this? (don't need to be Clojure, but more readable if so)

bensu avatar May 31 '16 17:05 bensu

I haven't had the same issue with other test frameworks. That might be because they are slower in detecting changes, tho. I don't know their internal workings.

I see that you're using cljs.build.api/watch to be notified of changes. I wonder what would happen if you just passed a debounced function to :watch-fn.

I'd be happy to try out a few things and report back to you, possibly with a pull request, if you're interested.

magnars avatar May 31 '16 18:05 magnars

Yes, :watch-fn would be a good place to wrap with a bounced function. There are some reasons to look for a guideline implementation:

  1. The default bounce time (50ms seems ok)
  2. Some API decisions like "is the bounce always on?" or "should the bounce time be configurable?"

I am definitely interest. Any progress you can make will speed things along, since I am running behind with general maintenance as I have been very busy lately.

bensu avatar Jun 01 '16 07:06 bensu

Some inspiration could be taken from lein auto. The wait time there is 50ms by default, as suggested, and changing the wait time is done like this in project.clj:

:auto {"doo" {:wait-time 500}}

I haven't tried it myself, but I guess you could probably set :wait-time to 0. Which would be the same as disabling it. :wait-time is passed directly to Thread/sleep, so there's no special value to disable.

Meanwhile, lein-test-refresh has a hardcoded sleep of 200ms before rerunning tests.

MatthewDarling avatar Sep 27 '17 16:09 MatthewDarling