nathany / looper

Go autotesting tool with readline support.
BSD 2-Clause "Simplified" License
390 stars 40 forks source link

Tests run twice #6

Open darkhelmet opened 11 years ago

darkhelmet commented 11 years ago

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

nathany commented 11 years ago

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 commented 11 years ago

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

darkhelmet commented 11 years ago

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)
nathany commented 11 years ago

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! :-)

darkhelmet commented 11 years ago

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 notifications@github.comwrote:

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 .

nathany commented 11 years ago

@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.

darkhelmet commented 11 years ago

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 commented 11 years ago
~/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)
nathany commented 11 years ago

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?

darkhelmet commented 11 years ago

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 notifications@github.com 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

nathany commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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

nathany commented 11 years ago

@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 commented 11 years ago

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 commented 11 years ago

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).

wavded commented 8 years ago

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?)

nathany commented 8 years ago

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
wavded commented 8 years ago

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.

nathany commented 8 years ago

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