Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Tests run twice #6

Open
darkhelmet opened this issue May 17, 2013 · 20 comments
Open

Tests run twice #6

darkhelmet opened this issue May 17, 2013 · 20 comments
Assignees
Labels

Comments

@darkhelmet
Copy link

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

@nathany
Copy link
Owner

nathany commented May 17, 2013

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.

@ghost ghost assigned nathany May 17, 2013
@nathany
Copy link
Owner

nathany commented Jun 23, 2013

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

@darkhelmet
Copy link
Author

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
Copy link
Owner

nathany commented Jun 24, 2013

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
Copy link
Author

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//issues/6#issuecomment-19889045
.

@nathany
Copy link
Owner

nathany commented Jul 6, 2013

@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
Copy link
Author

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
Copy link
Author

~/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
Copy link
Owner

nathany commented Jul 9, 2013

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
Copy link
Author

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:
#6 (comment)

@nathany
Copy link
Owner

nathany commented Jul 13, 2013

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
Copy link
Owner

nathany commented Sep 1, 2013

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
Copy link
Owner

nathany commented Sep 3, 2013

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

@nathany
Copy link
Owner

nathany commented Sep 21, 2013

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

@nathany
Copy link
Owner

nathany commented Sep 21, 2013

It has been pointed out that this is caused by Spotlight. howeyc/fsnotify#62

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

@nathany
Copy link
Owner

nathany commented Sep 22, 2013

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
Copy link

wavded commented Nov 20, 2015

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
Copy link
Owner

nathany commented Nov 21, 2015

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
Copy link

wavded commented Nov 21, 2015

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
Copy link
Owner

nathany commented Nov 21, 2015

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

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants