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

src: refactor coverage connection #26513

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

src: refactor coverage connection

  • Refactor the C++ class to be resuable for other types of profiles
  • Move the try-catch block around coverage collection callback
    to be inside the callback to silence potential JSON or write
    errors.
  • Use Function::Call instead of MakeCallback to call the coverage
    message callback since it does not actually need async hook
    handling. This way we no longer needs to disable the async
    hooks when writing the coverage results.
  • Renames lib/internal/coverage-gen/with_profiler.js to
    lib/internal/profiler.js because it is now the only way
    to generate coverage.

test: show stderr on v8 coverage test failures

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Mar 8, 2019
@joyeecheung joyeecheung changed the title Refactor coverage src: refactor coverage connection Mar 8, 2019
@joyeecheung
Copy link
Member Author

@addaleax addaleax added the coverage Issues and PRs related to native coverage support. label Mar 8, 2019
src/inspector_profiler.cc Outdated Show resolved Hide resolved
"Sending Profiler.startPreciseCoverage\n");
Isolate* isolate = this->env()->isolate();
Local<String> enable = FIXED_ONE_BYTE_STRING(
isolate, "{\"id\": 1, \"method\": \"Profiler.enable\"}");
Copy link
Member

Choose a reason for hiding this comment

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

Use raw string here ?

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me 👍 It's nice to be able to remove the confusing disableAllAsyncHooks methods.

Let's just make sure we run the coverage CI against this before we land? @mhdawson how far did we get on making this run as part of the smoke testing process?

- Refactor the C++ class to be resuable for other types of profiles
- Move the try-catch block around coverage collection callback
  to be inside the callback to silence potential JSON or write
  errors.
- Use Function::Call instead of MakeCallback to call the coverage
  message callback since it does not actually need async hook
  handling. This way we no longer needs to disable the async
  hooks when writing the coverage results.
- Renames `lib/internal/coverage-gen/with_profiler.js` to
  `lib/internal/profiler.js` because it is now the only way
  to generate coverage.
@joyeecheung
Copy link
Member Author

Rebased and addressed reviews. CI: https://ci.nodejs.org/job/node-test-pull-request/21434/

@gengjiawen Regarding raw strings: I have no idea why but it looks like neither we nor non-test V8 code use those, so I'd prefer leaving that out of this PR, in case there's any weird compiler support oddities. Feel free to open a separate PR to update those.

@joyeecheung
Copy link
Member Author

Screen Shot 2019-03-12 at 6 59 47 AM

I don't think there is a job to run the coverage CI against a PR. I do get a successful run locally though. If this comes back breaking the coverage, we can just revert.

@joyeecheung
Copy link
Member Author

Landed in 963ee0b...eb0bf8d

joyeecheung added a commit that referenced this pull request Mar 11, 2019
- Refactor the C++ class to be resuable for other types of profiles
- Move the try-catch block around coverage collection callback
  to be inside the callback to silence potential JSON or write
  errors.
- Use Function::Call instead of MakeCallback to call the coverage
  message callback since it does not actually need async hook
  handling. This way we no longer needs to disable the async
  hooks when writing the coverage results.
- Renames `lib/internal/coverage-gen/with_profiler.js` to
  `lib/internal/profiler.js` because it is now the only way
  to generate coverage.

PR-URL: #26513
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
joyeecheung added a commit that referenced this pull request Mar 11, 2019
PR-URL: #26513
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
@BridgeAR
Copy link
Member

This does not land cleanly on v11. It seems to rely on other commits that should be backported first. Please open a manual backport for it or change the labels accordingly.

targos pushed a commit that referenced this pull request Mar 28, 2019
- Refactor the C++ class to be resuable for other types of profiles
- Move the try-catch block around coverage collection callback
  to be inside the callback to silence potential JSON or write
  errors.
- Use Function::Call instead of MakeCallback to call the coverage
  message callback since it does not actually need async hook
  handling. This way we no longer needs to disable the async
  hooks when writing the coverage results.
- Renames `lib/internal/coverage-gen/with_profiler.js` to
  `lib/internal/profiler.js` because it is now the only way
  to generate coverage.

PR-URL: #26513
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
targos pushed a commit that referenced this pull request Mar 28, 2019
PR-URL: #26513
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
targos pushed a commit that referenced this pull request Mar 30, 2019
- Refactor the C++ class to be resuable for other types of profiles
- Move the try-catch block around coverage collection callback
  to be inside the callback to silence potential JSON or write
  errors.
- Use Function::Call instead of MakeCallback to call the coverage
  message callback since it does not actually need async hook
  handling. This way we no longer needs to disable the async
  hooks when writing the coverage results.
- Renames `lib/internal/coverage-gen/with_profiler.js` to
  `lib/internal/profiler.js` because it is now the only way
  to generate coverage.

PR-URL: #26513
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
targos pushed a commit that referenced this pull request Mar 30, 2019
PR-URL: #26513
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coverage Issues and PRs related to native coverage support. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants