Skip to content

Conversation

eugeneo
Copy link
Contributor

@eugeneo eugeneo commented Jul 24, 2017

Helper was rewritten to rely on promises instead of manually written
queue and callbacks. This simplifies the code and makes it easier to
maintain and extend.

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: 2 of the inspector tests were rewritten with a new framework.

This is a work in progress. I would be grateful for any feedback before I port other tests on this new helper API.

@nodejs-github-bot nodejs-github-bot added dont-land-on-v4.x inspector Issues and PRs related to the V8 inspector protocol test Issues and PRs related to the tests. labels Jul 24, 2017
@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 26, 2017

Newer helper uses port 0 by default. Also it should now be possible to run multiple children processes (no test uses this yet).

@TimothyGu
Copy link
Member

Very nice! I've implemented something like this but for inspector.Session in my VM context PR so I've got a couple suggestions. I'm on my phone though so will post them later.

@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 28, 2017

@TimothyGu I would really appreciate your suggestions.

I've been thinking about having a test framework that can run tests both through WebSockets and JS bindings to improve the coverage. But I am also working on moving WS codepath to use JS bindings to talk to inspector - that should make JS bindings tests less important.

@TimothyGu TimothyGu self-assigned this Jul 31, 2017
Copy link
Member

Choose a reason for hiding this comment

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

This could be added to test/common/index.js, or you can just take my version instead :) https://github.com/TimothyGu/node/blob/15a8ff8f52a8e01f41e773ea1f4e970976625aac/test/common/index.js#L820-L838 (docs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied you version - but the issue I noticed is that the test will not complete until the timeout is fired. I implemented the timeout clearing.

Copy link
Member

Choose a reason for hiding this comment

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

Arrow functions are preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

In Node.js private properties are usually prefixed with _ not postfixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

waiting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Array.isArray

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Where is enqueue_ defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I deleted "kill" (for now). It was copied from the old test and "enqueu_" is a primary reason the tests have to be rewritten :)

Copy link
Member

Choose a reason for hiding this comment

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

Is this function intended to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made it a standalone non-exported function.

Copy link
Member

Choose a reason for hiding this comment

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

You might want to use common.crashOnUnhandledRejection()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

I know it doesn't matter most of the cases, but I prefer using once instead of on with promises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

WS stuff should be factored out of this function (much like parseWSFrame above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 31, 2017

@TimothyGu Thank you for your review. Please take another look. I am more confident in this approach now so I will try to find time and port other tests now.

Copy link
Member

Choose a reason for hiding this comment

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

docs should be added to test/common/README.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I also ported a couple more test cases.

Note - I pushed a new change as a separate commit to make it easier to use the GitHub UI - I will do a proper rebase/squish before submitting the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

finally is a reserved word. I considered promiseFinally or onFinally - but decided to be explicit...

Copy link
Member

Choose a reason for hiding this comment

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

One hackish way around that is to set the name property on the function after it is defined. E.g.

function onResolvedOrRejected(promise, callback) { /* ... */ }
onResolvedOrRejected.name = 'finally';

But I definitely do not see that as being critical.

@eugeneo
Copy link
Contributor Author

eugeneo commented Aug 3, 2017

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

I ported all the tests to a new framework. I also renamed test cases to remove "-inspector" from the file name - they all reside in the "inspector" folder so there is no need to repeat it in the file name.

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

This needs a rebase...

Copy link
Member

Choose a reason for hiding this comment

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

Debugging console.logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed :)

@eugeneo
Copy link
Contributor Author

eugeneo commented Aug 9, 2017

Performed a rebase. New CI: https://ci.nodejs.org/job/node-test-pull-request/9578/

@eugeneo
Copy link
Contributor Author

eugeneo commented Aug 10, 2017

Apparently, last CI run was cancelled. New CI: https://ci.nodejs.org/job/node-test-pull-request/9603/

@eugeneo eugeneo closed this Aug 10, 2017
@eugeneo eugeneo deleted the promisify-test branch August 10, 2017 23:36
@eugeneo
Copy link
Contributor Author

eugeneo commented Aug 10, 2017

CI did not show any relevant failures. This PR landed as https://github.com/eugeneo/node/commit/2296b677fb1e2ea71e86a899b028ba9e817e86ad.

@eugeneo eugeneo merged commit 2296b67 into nodejs:master Aug 10, 2017
addaleax added a commit to addaleax/node that referenced this pull request Aug 11, 2017
This reverts commit 2296b67.

That commit was landed without a green CI and is failing on Windows.

Ref: nodejs#14460
@addaleax
Copy link
Member

@eugeneo The last CI run linked here is for a different PR, this patch makes CI fail on Windows; revert is in #14777

addaleax added a commit that referenced this pull request Aug 11, 2017
This reverts commit 2296b67.

That commit was landed without a green CI and is failing on Windows.

Ref: #14460
PR-URL: #14777
Reviewed-By: Refael Ackermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inspector Issues and PRs related to the V8 inspector protocol test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants