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: improve the code in test-fs-read-stream #10556

Closed
wants to merge 1 commit into from

Conversation

edsadr
Copy link
Member

@edsadr edsadr commented Dec 31, 2016

  • use const and let instead of var
  • use common.mustCall to control function execution
  • use assert.strictEqual instead of assert.equal
  • use arrow functions
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added test Issues and PRs related to the tests. lts-watch-v6.x labels Dec 31, 2016
@mscdex mscdex added the fs Issues and PRs related to the fs subsystem / file system. label Dec 31, 2016
const fd = fs.openSync(file, 'r');
const stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' });

stream.on('data', common.mustCall((data) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the common.mustCall() should be removed since there could be more than one 'data' event and we're already verifying the output on process exit anyway.


process.on('exit', function() {
process.on('exit', () => {
fs.unlinkSync(file);
Copy link
Member

Choose a reason for hiding this comment

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

While we're in here editing the file, can you please remove fs.unlinkSync(file);? (There's no need for tests to clean up the temp dir on exit as all tests that use the temp dir should refresh it before using it.)

@edsadr
Copy link
Member Author

edsadr commented Jan 2, 2017

@mscdex @Trott ... implemented both suggestions...

@mscdex
Copy link
Contributor

mscdex commented Jan 2, 2017

LGTM

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM if CI is ✅

@Trott
Copy link
Member

Trott commented Jan 2, 2017

Copy link
Contributor

@evanlucas evanlucas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions
@edsadr
Copy link
Member Author

edsadr commented Jan 3, 2017

solved the conflicts after ff1efa6 , please set the CI again

@italoacasas
Copy link
Contributor

@italoacasas
Copy link
Contributor

Landed 7a46b99

@italoacasas italoacasas closed this Jan 3, 2017
italoacasas pushed a commit that referenced this pull request Jan 3, 2017
* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: #10556
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: nodejs#10556
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 19, 2017
* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: nodejs#10556
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
targos pushed a commit that referenced this pull request Jan 28, 2017
* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: #10556
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
@italoacasas italoacasas mentioned this pull request Jan 29, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: nodejs#10556
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use arrow functions

PR-URL: nodejs#10556
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants