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: refactor test-fs-read-stream-inherit #13618

Closed
wants to merge 1 commit into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Jun 11, 2017

  • block scope paused
  • change name of block-scoped file3 etc. to file
  • alphabetize modules
  • confirm contents provided in data callback
  • confirm data callbacks will not fire on tests for errors
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test fs

* block scope `paused`
* change name of block-scoped `file3` etc. to `file`
* alphabetize modules
* confirm contents provided in `data` callback
* confirm `data` callbacks will not fire on tests for errors
@Trott Trott added fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests. labels Jun 11, 2017
file3.on('data', function(data) {
const file = fs.createReadStream(fn, Object.create({encoding: 'utf8'}));
file.length = 0;
file.on('data', function(data) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we have any preferences whether to use lambdas or good old function declarations when they are interchangeable?

Copy link
Member

Choose a reason for hiding this comment

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

By lambdas you mean () => {} (fat arrow) functions? I don't think we have an official policy (although I personally prefer fat arrow functions because they seem simpler).

Copy link
Member

Choose a reason for hiding this comment

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

@gibfahn Exactly, that would be my preference as well.

file5.on('end', common.mustCall(function() {
assert.strictEqual(file5.data, 'yz\n');
file.on('end', common.mustCall(function() {
assert.strictEqual(file.data, 'yz\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're here could you parameterize the 'yz\n', here and in L106

file7Next();
assert(!file.closed);
assert(!file.destroyed);
assert.strictEqual(data, 'xyz\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

file7.data = '';
file7.on('data', function(data) {
file7.data += data;
file = fs.createReadStream(null, Object.create({fd: file.fd, start: 0 }));
Copy link
Contributor

Choose a reason for hiding this comment

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

this is just weird, shadowing file but AFAICT only affects L147-8 , so there it asserts the state of this file 🤔
IMHO it's wrong, but maybe not for this PR...

@Trott
Copy link
Member Author

Trott commented Jun 14, 2017

@Trott
Copy link
Member Author

Trott commented Jun 14, 2017

Landed in 3c506af

@Trott Trott closed this Jun 14, 2017
Trott added a commit to Trott/io.js that referenced this pull request Jun 14, 2017
* block scope `paused`
* change name of block-scoped `file3` etc. to `file`
* alphabetize modules
* confirm contents provided in `data` callback
* confirm `data` callbacks will not fire on tests for errors

PR-URL: nodejs#13618
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this pull request Jun 17, 2017
* block scope `paused`
* change name of block-scoped `file3` etc. to `file`
* alphabetize modules
* confirm contents provided in `data` callback
* confirm `data` callbacks will not fire on tests for errors

PR-URL: #13618
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@addaleax addaleax mentioned this pull request Jun 17, 2017
addaleax pushed a commit that referenced this pull request Jun 21, 2017
* block scope `paused`
* change name of block-scoped `file3` etc. to `file`
* alphabetize modules
* confirm contents provided in `data` callback
* confirm `data` callbacks will not fire on tests for errors

PR-URL: #13618
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@addaleax addaleax mentioned this pull request Jun 21, 2017
@MylesBorins
Copy link
Contributor

This does not land cleanly in LTS. Please feel free to manually backport. Please also feel free to replace do-not-land if it is being backported

@Trott Trott deleted the moar-refactoring-fs-tests branch January 13, 2022 22:45
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.

8 participants