-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 tests for stream3 buffering using cork #6493
Conversation
@nodejs/streams |
Thanks!!! You might want to check this runs on node v4, just in case. I think we should start the habit of explaining the tests in plain English first, because otherwise they imply a lot of knowledge around the stream state machine and they might scare newcomers. Most of it is already explained in the comments, it's probably just a matter of putting a paragraph to describe it at the beginning. Use How about you add a test also for |
Thanks for the feedback @mcollina - so I've just pushed an update with the following changes:
Regarding Finally, happy to add a paragraph but the question would be where and using /* */ or multiple // ? Could you perhaps point me to another file where this is done, keen to follow not set any precedents for now :) |
that would be amazing as for comment style I believe they tend to be |
// there was a chunk | ||
assert.ok(seen); | ||
|
||
var expected = new Buffer(expectedChunks[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffer.from(expectedChunks[i])
Left a couple nits pointing where |
@jasnell appreciate you taking a look! I'm happy to do that, but per discussions of @nodejs/streams it may be preferable to allow these to run against all versions of node that implement streams3. What could be worth an explicit decision is if that should be evident within 'in-tree' files or if any necessary glue be added in ports to readable-stream repo. |
Works for me... as I said, feel free to ignore ;-) That's actually the main reason why I didn't go through all of the existing tests and change them to use Come to think of it, as a best practice it might be a good idea to explicitly indicate (using code comments) in the tests themselves which node.js versions the test needs to be able to run on. |
Yes, please. My dream is to eventually have that information as metadata in test comments so that an automated process can confirm that changes to tests don't suddenly make them pass in versions where they are supposed to fail. But that is way beyond the scope of this PR. :-) |
👍 on writing a comment stating on which node version this belongs to. |
I'll look at adding those descriptive paragraphs - as for versioning, any objection to the following: // node version target: 0.12 |
Just updated these two tests to address comments:
I also renamed consumeChunks() -> writeChunks() to better its behaviour. |
Apart for the two |
fyi I've got a shim working so I can run the readable streams (including the Buffer.from) against old node |
@mcollina @calvinmetcalf re It's easy enough to conditionally check for the Buffer method etc, but it's still unclear whether the in-tree tests should target the lowest version of node (thus compat glue be added in test) or if it is ok for this to be handled in the readable-streams repo. |
Given the requirement that readable-stream has to support older versions of Node I think not going with the Buffer.from() here is appropriate. |
sorry, to clarify this is handled in readable-stream already |
Seems like I can leave the files as is with 'new Buffer()'. Given previous LGTMs, is there anything else I should do before these can be landed? |
LGTM if @nodejs/streams is good with it. |
yup it's good, merged |
Awesome, thanks! Very glad this was useful. |
adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: #6493 Reviewed-By: James M Snell <jasnell@gmail.com>
@nodejs/streams should this be backported to v4? |
@thealphanerd Ideally yes, if it is not passing ping us. |
adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: #6493 Reviewed-By: James M Snell <jasnell@gmail.com>
adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: #6493 Reviewed-By: James M Snell <jasnell@gmail.com>
adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: #6493 Reviewed-By: James M Snell <jasnell@gmail.com>
adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: #6493 Reviewed-By: James M Snell <jasnell@gmail.com>
adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: #6493 Reviewed-By: James M Snell <jasnell@gmail.com>
adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: #6493 Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
Description of change
Add tests of stream3 the buffering behaviour of cork() followed by uncork()/end(). Opening a PR for review per request of the streams-wg.
cc @nodejs/readable-stream