Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushes test coverage just over 50% #18

Merged
merged 4 commits into from
Oct 25, 2016
Merged

Pushes test coverage just over 50% #18

merged 4 commits into from
Oct 25, 2016

Conversation

nathany
Copy link
Contributor

@nathany nathany commented Oct 13, 2016

resolves merge conflicts in #15 from @drewwells

Pushes test coverage just over 50%

I broke all C calls into a separate file "wrap.go" and wrapped some types in Go types. This way, fsevents.go does not import "C". In addition, testing can not import C, so it makes it easier to test the different methods. There's several extra functions added to allow better inspection of FSEventStreamRef for testing the correct setup of File Event stream.

FSEventStreamRef should probably become a struct that wraps the underlying C.FSEventStreamRef. This would remove some of the ugly GetStreamRefXXX. I'm also open to making most of the GetStreamRefXXX calls private, since it's unlikely consumers will actually call these. We should likely rely on the GetStreamRefPaths for reporting the actual paths being watched.

Also, nothing in this actually tests a live filesystem event.

It does test:

  • a real device ID is being targeted
  • registry does what it claims to do
  • FSEvents UUID can be pulled for the device ID
  • FSEventStream is correctly setup and watching specified paths

@nathany
Copy link
Contributor Author

nathany commented Oct 13, 2016

Travis CI is having some problems. https://www.traviscistatus.com/

Btw, I've been force pushing travis ci configs to this branch. Yell at me to stop if you need me to.

Copy link
Contributor Author

@nathany nathany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm too 💤 and too inexperienced with FSEvents to do a proper review, but I left a few comments. Of course I'm happy to make such minor revisions on this branch -- or even leave them for after.

Would be great if @samjacobson and/or someone else could take a look.

@@ -13,18 +14,24 @@ import (
)

func main() {
dev, _ := fsevents.DeviceForPath("/tmp")
path := "/tmp"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be os.TempDir()?

es.Start()
ec := es.Events

fmt.Println("Device UUID", fsevents.GetDeviceUUID(dev))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could just use log.Println since everything else in the file does

path := "/tmp"
dev, err := fsevents.DeviceForPath(path)
if err != nil {
log.Println("Failed to retrieve device for path:", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be log.Fatal?


es.Events <- events
}

// LatestEventID returns the most recently generated event ID, system-wide.
func LatestEventID() uint64 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not everything in wrap.go is unexported, so maybe just move this function there

// You can provide your own event channel if you wish (or one will be
// created on Start).
//
// es := &EventStream{Paths: []string{"/tmp"}, Flags: 0}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code snippet doesn't render so well in godoc. not sure if it could be made into a (working) example? though an example need not be executed, so long as it compiles

http://127.0.0.1:8080/pkg/github.com/fsnotify/fsevents/

godoc


es.stream = setupStream(paths, es.Flags, callbackInfo, since, es.Latency, es.Device)

started := make(chan struct{})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the addition that caused the merge conflict, see #18


// CFArrayLen retrieves the length of CFArray type
// See https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFArrayRef/#//apple_ref/c/func/CFArrayGetCount
func CFArrayLen(ref C.CFArrayRef) int {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we don't want to export this?

paths := []string{"/a", "/b"}
ref := setupStream(paths, 0, 0, eid, time.Duration(0), did)

t.Log(GetStreamRefDescription(ref))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we want to keep this log in the tests?

@nathany
Copy link
Contributor Author

nathany commented Oct 13, 2016

Once Travis CI is up and working again, we can force a rebuild and see if I got the config right for macOS. I'm planning to setup https://codecov.io/ as well.

@codecov-io
Copy link

codecov-io commented Oct 13, 2016

Current coverage is 43.03% (diff: 41.30%)

No coverage report found for master at cb6277d.

Powered by Codecov. Last update cb6277d...ce7b5c6

@nathany
Copy link
Contributor Author

nathany commented Oct 13, 2016

Test coverage for this branch can be viewed here: https://codecov.io/gh/fsnotify/fsevents/branch/testmock

I've asked @stevepeak why the discrepancy between coverage % on codecov.io and running it on the command line.

@samjacobson
Copy link
Contributor

I'm under the gun with another project at the moment. I can take a look
early to mid next week if that's at all helpful.

Cheers

Sam

On Fri, Oct 14, 2016 at 6:10 AM, Nathan Youngman notifications@github.com
wrote:

Test coverage can be viewed here: https://codecov.io/gh/
fsnotify/fsevents/branch/testmock

I've asked @stevepeak https://github.com/stevepeak why the discrepancy
between coverage % on codecov.io and running the command line.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#18 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABMJvcITecow-mw0UANA6E5Vgv5CGZL1ks5qzmXygaJpZM4KVZu0
.

@nathany
Copy link
Contributor Author

nathany commented Oct 13, 2016

Thanks Sam. That would be wonderful.

@nathany
Copy link
Contributor Author

nathany commented Oct 18, 2016

@drewwells Do you have the time to continue working on this?

@drewwells
Copy link
Contributor

Yeah I can look at it tomorrow

@drewwells
Copy link
Contributor

It doesn't appear that I have push access to this PR, I'll open a PR against it then

@nathany
Copy link
Contributor Author

nathany commented Oct 19, 2016

Sorry @drewwells. I've adjusted the settings.

drewwells and others added 4 commits October 25, 2016 11:21
fix vet errors in fsevtCallback
separate all parts that call C code into separate wrap file
test registry functions
test creating of paths
test inspects StreamRef to ensure setupStream created it correctly
@nathany
Copy link
Contributor Author

nathany commented Oct 25, 2016

Travis CI is very slow at starting the macOS tests. We are enabled to use CircleCI now, but the yml file needs configuring. https://circleci.com/gh/fsnotify/fsevents

This is what I had to do before, but it may have changed since.
fsnotify/fsnotify@c733143

https://circleci.com/docs/ios-builds-on-os-x/

@drewwells
Copy link
Contributor

Why is codecov failing? This MR should be significantly increasing coverage from master.

I can look into the circleci issue, that should probably be in a separate PR so this one doesn't get too overwhelming.

@nathany
Copy link
Contributor Author

nathany commented Oct 25, 2016

I don't know what the deal is with codecov. Let's see what happens on the next pull request.

@nathany nathany merged commit b319f15 into master Oct 25, 2016
@nathany nathany deleted the testmock branch October 25, 2016 20:54
@nathany
Copy link
Contributor Author

nathany commented Oct 25, 2016

@samjacobson I went ahead and merged this, but feel free to review and open PRs or issues if you see something that can be improved. Thanks!

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

Successfully merging this pull request may close these issues.

4 participants