looper icon indicating copy to clipboard operation
looper copied to clipboard

Tests run twice

Open darkhelmet opened this issue 11 years ago • 20 comments

Not that it's slow, but when I make a simple change, it runs the tests twice. How does software even work?

darkhelmet avatar May 17 '13 06:05 darkhelmet

It's possible it's getting two events. Are you saving one *.go file? May be related to atomic saves.

I'll see if I can reproduce it. It may be necessary to add some throttling now that any change tests the entire package.

nathany avatar May 17 '13 14:05 nathany

@darkhelmet I'm going to need more info to reproduce this issue. Steps to reproduce, yo?

nathany avatar Jun 23 '13 15:06 nathany

I'm using my github.com/darkhelmet/blargh package, go in a edit/save post.go, and it runs twice.

go test ./post
ok      github.com/darkhelmet/blargh/post   0.053s
PASS (0.59 seconds)
go test ./post
ok      github.com/darkhelmet/blargh/post   0.060s
PASS (0.57 seconds)

darkhelmet avatar Jun 24 '13 04:06 darkhelmet

Saving from Sublime Text? (v 2.0.1)? What settings are you using for saving? Gofmt, etc.? I pulled your repo and wasn't able to reproduce it.

I should probably add a --debug option to log what's coming from the watcher. I know prettytest has a bunch of code to throttle the watcher, but this is the first time I've seen a need for it. Your computer must be smoking fast! :-)

nathany avatar Jun 24 '13 04:06 nathany

I wonder if it's gofmt running.

There would be the save, then gofmt...

On Sun, Jun 23, 2013 at 10:52 PM, Nathan Youngman [email protected]:

Saving from Sublime Text? (v 2.0.1)?

I should probably add a --debug option to log what's coming from the watcher. I know prettytest has a bunch of code to throttle the watcher, but this is the first time I've seen a need for it. Your computer must be smoking fast! :-)

— Reply to this email directly or view it on GitHubhttps://github.com/gophertown/looper/issues/6#issuecomment-19889045 .

darkhelmet avatar Jun 24 '13 05:06 darkhelmet

@darkhelmet Can you try looper 0.2.1 with looper --debug and let me know what output you get?

I noticed I'm getting new file events when I expected change file events here.

nathany avatar Jul 06 '13 20:07 nathany

I get Detected file modification post/post.go, then it runs go test ./post, then Detected file modification post/post.go again, then the test again.

Even turning off gofmt doesn't change anything.

darkhelmet avatar Jul 06 '13 23:07 darkhelmet

~/dev/go/src/github.com/darkhelmet/blargh (master) » looper -debug
Looper 0.2.1 is watching your files
Type help for help.

Debug mode enabled.

Watching path ./
Watching path errors
Watching path filerepo
Watching path filerepo/test
Watching path filerepo/test/repo
Watching path filerepo/test/sort
Watching path html
Watching path html/atom
Watching path html/testdata
Watching path html/testdata/webkit
Watching path html/testdata/webkit/scripted
Watching path post
Watching path post/test
Detected file modification post/post.go
go test ./post
Detected file modification post/post.go
ok      github.com/darkhelmet/blargh/post   0.057s
PASS (0.58 seconds)
go test ./post
ok      github.com/darkhelmet/blargh/post   0.056s
PASS (0.56 seconds)

darkhelmet avatar Jul 06 '13 23:07 darkhelmet

Hm. That doesn't tell us much. Guess I just need some throttling in place.

Is the fsnotify package up-to-date on your computer?

nathany avatar Jul 09 '13 03:07 nathany

I installed with -u -v and I believe I remember it updating that package.  — Sent from Mailbox for iPhone

On Mon, Jul 8, 2013 at 11:27 PM, Nathan Youngman [email protected] wrote:

Hm. That doesn't tell us much. Guess I just need some throttling in place.

Is the fsnotify package up-to-date on your computer?

Reply to this email directly or view it on GitHub: https://github.com/gophertown/looper/issues/6#issuecomment-20651295

darkhelmet avatar Jul 09 '13 03:07 darkhelmet

Before adding some sort of throttling to my RecursiveWatcher, I emailed @howeyc to see if this is something that can be resolved in fsnotify or if I just made a dumb mistake in my use of it.

nathany avatar Jul 13 '13 00:07 nathany

For some reason this is happening to me now, which will make it a lot easier to debug. @howeyc didn't feel that a ThrottledWatcher belonged in fsnotify proper, but I'm starting work on a fsnotify-ext package.

nathany avatar Sep 01 '13 02:09 nathany

Started on https://github.com/gophertown/fsnotify_ext, but still a lot to do!

nathany avatar Sep 03 '13 05:09 nathany

@darkhelmet I have an open pull request to throttle events in fsnotify https://github.com/howeyc/fsnotify/pull/65. Testing it out with Looper now.

nathany avatar Sep 21 '13 22:09 nathany

It has been pointed out that this is caused by Spotlight. https://github.com/howeyc/fsnotify/issues/62

One solution is to add your development folder to the Spotlight Privacy settings, at least until we have a better option.

nathany avatar Sep 21 '13 22:09 nathany

Related issue: running the tests for code.google.com/p/go.tools/cmd/cover generates Go code in testdata, which triggers the tests. Need some way to ignore certain folders (.looperignore).

nathany avatar Sep 22 '13 17:09 nathany

My tests run three times currently from vim (lucky me) on OSX whenever I save a change. Would it be worth ignoring a small window of file notification activity when receiving a change event to avoid this? (like 50/100 ms?)

wavded avatar Nov 20 '15 08:11 wavded

That might work. Hugo has something like that in place.

I'm not a vim user, but besides modifying Spotlight Privacy settings (mentioned above), you could also try tweaking your .vimrc file. These settings are from thoughtbot's config

set nobackup
set nowritebackup
set noswapfile

nathany avatar Nov 21 '15 17:11 nathany

Thx @nathany. Modifying the vim config dropped one of the three. Adding the project folder to Spotify Privacy didn't seem to have any effect.

wavded avatar Nov 21 '15 18:11 wavded

Progress.

This is Hugo's code to batch up notifications. Not sure when I'll get a chance to implement it, but I'd welcome a pull request. :wink:

https://github.com/spf13/hugo/blob/master/watcher/batcher.go

nathany avatar Nov 21 '15 19:11 nathany