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 lib/internal/readline/promises.js coverage #42420

Merged

Conversation

fossamagna
Copy link
Contributor

This improves a test coverage in lib/internal/readline/promises.js

ref: https://coverage.nodejs.org/coverage-419f02ba1f00cac3/lib/internal/readline/promises.js.html

This validates that autoCommit option work correctly.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Mar 21, 2022
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

I think we can remove the test functions

test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
@fossamagna
Copy link
Contributor Author

fossamagna commented Mar 22, 2022

@aduh95
Thank you for your review.

I removed test function in response to take your suggestion, but test got following error.

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ '\x1B[1K\x1B[0K'
- '\x1B[0K'
        ^

When use autoCommit option, readline write to stream in callback function of process.nextTick. If we removed test function, before readline write to stream and test assertion, invocation of clearLine function in for-of loop will be finished.

@fossamagna fossamagna requested a review from aduh95 March 23, 2022 13:06
@aduh95
Copy link
Contributor

aduh95 commented Mar 23, 2022

@fossamagna I suggest using await setImmediate from timers/promises instead of a test function + process.nextTick, that should solve the problem and hopefully be more readable. Let me know if that works for you.

using `await setImmediate` instead of `test` function + process.nextTick.
@fossamagna
Copy link
Contributor Author

@aduh95 Thank you very much for your suggestion.
It works like a charm and have been more readable.

test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
test/parallel/test-readline-promises-csi.mjs Outdated Show resolved Hide resolved
@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Mar 25, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 26, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 3, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 3, 2022
@nodejs-github-bot nodejs-github-bot merged commit 95f94cf into nodejs:master Apr 3, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 95f94cf

@juanarbol
Copy link
Member

Dependent of #37947

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. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants