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

test: add block-scoping to test-fs-watch-encoding #25532

Closed
wants to merge 1 commit into from

Conversation

LakshmiSwethaG
Copy link
Contributor

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jan 16, 2019
BethGriggs
BethGriggs previously approved these changes Jan 17, 2019
jasnell
jasnell previously approved these changes Jan 17, 2019
Copy link
Contributor

@sam-github sam-github left a comment

Choose a reason for hiding this comment

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

Hi Lakshmi, thanks for the contribution, but I'm not in favour. Rockets (() => {} ) are useful for inline functions, and while it is possible to create a rocket, then assign it to a const to emulate the function ... syntax, its less clear when used like this, and even textually longer. I don't think this is a class of change we want to make in node. There are 790+ instances of this in test/parallel alone, much less the rest of node, but I'm not aware of any cases of "const rockets" at the file scope.

There are lots of things that can be improved about our test suites, maybe we can find some other kinds of refactorings you would be interested in working on?

@Trott
Copy link
Member

Trott commented Jan 18, 2019

@LakshmiSwethaG Welcome and thanks for the pull request! I agree with @sam-github that this is not a desirable change. However, instead, in the same file, perhaps you can refactor it to block-scope things so that we don't have watcher1, watcher2, and watcher3?

For example, instead of this:

const watcher1 = fs.watch(
  tmpdir.path,
  { encoding: 'hex' },
  (event, filename) => {
    if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename))
      done(watcher1);
  }
);
registerWatcher(watcher1);

...it could be block-scoped like this:

{
  const watcher = fs.watch(
    tmpdir.path,
    { encoding: 'hex' },
    (event, filename) => {
      if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename))
        done(watcher);
    }
  );
  registerWatcher(watcher);
}

...and similarly for watcher2 and watcher3.

Then, a comment can be added to each of the three block-scopes explaining exactly what it is testing. One short sentence or sentence fragment in each case should be enough. So the block above, might have this comment added to it:

// Test that using the `encoding` option has the expected result.

@LakshmiSwethaG
Copy link
Contributor Author

@sam-github and @Trott Thanks for your suggestions. I have updated the commit with @Trott suggestions. Please review and suggest.
Sorry for the delay in response I didn't have access to any system.

@Trott Trott changed the title test: Changed the traditional functions to arrow test: add block-scoping to test-fs-watch-encoding Jan 27, 2019
@Trott Trott dismissed stale reviews from jasnell, sam-github, BethGriggs, and gireeshpunathil January 27, 2019 17:20

PR is completely different from initial PR. Needs re-review. Dismissing all existing reviews.

@Trott
Copy link
Member

Trott commented Jan 27, 2019

@Trott
Copy link
Member

Trott commented Jan 28, 2019

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 28, 2019
@Trott
Copy link
Member

Trott commented Jan 28, 2019

Should probably wait 48 hours from #25532 (comment) before landing. Otherwise, this seems good to land (unless someone notices something and comments between now and then).

@addaleax
Copy link
Member

addaleax commented Feb 8, 2019

Landed in 0f0e7f5 🎉

@addaleax addaleax closed this Feb 8, 2019
addaleax pushed a commit that referenced this pull request Feb 8, 2019
PR-URL: #25532
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax pushed a commit that referenced this pull request Feb 8, 2019
PR-URL: #25532
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@targos targos mentioned this pull request Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants