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: Updates to test-stream2-unpipe-drain #10033

Conversation

storytimesolutions
Copy link
Contributor

Checklist
  • [X ] make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • [X ] tests and/or benchmarks are included
  • [X ] documentation is changed or added
  • [X ] commit message follows commit guidelines
Affected core subsystem(s)
Description of change
  1. Change var to const and let
  2. Remove dependency crypto
  3. Use common.mustCall rather than assert.equal

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 1, 2016
@imyller imyller added code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. dgram Issues and PRs related to the dgram subsystem / UDP. stream Issues and PRs related to the stream subsystem. and removed dgram Issues and PRs related to the dgram subsystem / UDP. labels Dec 1, 2016
var assert = require('assert');
var stream = require('stream');
const common = require('../common');
const stream = require('stream');
Copy link
Contributor

Choose a reason for hiding this comment

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

This require() could move down below the common.hasCrypto check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updates made per recommendation.

@@ -55,6 +51,6 @@ src1.once('readable', function() {


process.on('exit', function() {
assert.equal(src1.reads, 2);
assert.equal(src2.reads, 2);
common.mustCall(src1._read, 2);
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 incorrect. common.mustCall() should be added prior to the process.on('exit', ...) handler.

Copy link
Member

Choose a reason for hiding this comment

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

@storytimesolutions If you want to make this land-able quickly, you can remove the common.mustCall() additions and restore the assert.equal() statements but use assert.strictEqual() instead.

In thie particular case, the common.mustCall() approach (which is generally preferred) is a bit trickier than it usually is.

@storytimesolutions
Copy link
Contributor Author

@Trott Thanks for the advice. Implemented.

@italoacasas
Copy link
Contributor

@Trott
Copy link
Member

Trott commented Dec 23, 2016

@cjihrig Code has been changed to address your comment. PTAL at your convenience and update your review if appropriate. Thanks!

@Trott
Copy link
Member

Trott commented Dec 23, 2016

@storytimesolutions This code fails hard because the assert module has been removed from the test.

@@ -30,12 +27,11 @@ function TestReader(id) {
util.inherits(TestReader, stream.Readable);

TestReader.prototype._read = function(size) {
this.reads += 1;
this.push(crypto.randomBytes(size));
this.push(Buffer.alloc(size));
Copy link
Contributor

Choose a reason for hiding this comment

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

If this isn't using crypto to push data to the stream, the common.hasCrypto check is still needed?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, it can go too. Good catch.

@Trott
Copy link
Member

Trott commented Dec 28, 2016

...and the assertions are comparing functions to integers, so the assertions will always fire...

1. Change var to const
2. Remove dependency crypto
@Trott
Copy link
Member

Trott commented Dec 28, 2016

Since the fixes were relatively small, I went ahead and made them and pushed them to this PR. Hope that's OK, @storytimesolutions!

@cjihrig Can you confirm that this corrects the issues you flagged and, if so, please update your review? Thanks!

New CI: https://ci.nodejs.org/job/node-test-pull-request/5611/

Copy link
Contributor

@cjihrig cjihrig 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 the CI is happy

@italoacasas
Copy link
Contributor

Landed 627fa93

italoacasas pushed a commit that referenced this pull request Dec 29, 2016
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This was referenced Jan 24, 2017
MylesBorins pushed a commit that referenced this pull request Jan 31, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Feb 1, 2017
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. stream Issues and PRs related to the stream subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants