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

Patches #73

Merged
merged 2 commits into from
Dec 31, 2018
Merged

Patches #73

merged 2 commits into from
Dec 31, 2018

Conversation

Krinkle
Copy link
Contributor

@Krinkle Krinkle commented Dec 30, 2018

This pull request is mostly the result of me making small changes while learning how node-watch works when investigating #69.

The actual bug fix I will submit separately :)

See commit messages.

This follows-up on d56a4cd, which I accidentally passed
`counter` as the third parameter to watchDirectory(), which is
meant for `fn`.

The consequence is that when watching directories recursively
on Linux, it will call `self.on('change', fn)` multiple times.

In the Travis CI output for Linux, it now says:

> (node:4378) MaxListenersExceededWarning:
> Possible EventEmitter memory leak detected.
> 11 change listeners added.

This is not a failure, but it is a good warning that helped
expose this bug.
* Some tests assert inside the watch callback, and some tests
  assert outside the watch callback.
  Asserting from the outside, I think, makes the test easier to
  understand when there is a failure. Asserting from inside the
  watch callback, it can cause a confusing error if it gets called
  multiple times (due to it calling 'done()' multiple times,
  which Mocha does not allow).

* Use assert.equal(a, b) instead of assert(a === b) so that
  Mocha can report in the command-line what "actual" value is.

* Use on('ready') inside the tests to avoid the delay of 200ms.

* Use on('close', done) inside beforeEach().

* Use delay:0 in most tests, except those that test the
  de-duplication behaviour. And, reduce the time distance between
  modifications from 300ms to 100ms so that the tests run much faster.

  It seems that distances shorter than 100ms might not be detected
  by fs.FSWatcher, so I did not make it smaller than that.
  This is based on testing on macOS with Node 10, and testing on
  Travis CI.

* Set `--slow 500` parameter.
  The default in Mocha is 2000ms for error timeout,
  and 75ms for "slow" (marked with red color).
  The timeout is big enough, but the red color is too common
  on node-watch, I think. Increase from 75ms to 500ms so that we
  do not have red colors unless there is a problem.

The tests now take about 4 seconds (previously, 29s).
@yuanchuan
Copy link
Owner

This improves a LOT !!
I really love how you write commit messages. Really appreciated your work :)

@yuanchuan yuanchuan merged commit 079c612 into yuanchuan:master Dec 31, 2018
@Krinkle Krinkle deleted the patches branch December 31, 2018 03:37
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.

None yet

2 participants