-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(unstable): deno test --coverage #6901
Conversation
@caspervonb Would it be something similar to |
Not sure what jest does but this collects block based call coverage directly from the runtime. Output formats to be determined but lcov is fairly obvious as it's a ubiquitous format. |
cli/coverage.rs
Outdated
// TODO(caspervonb) do not hard-code message ids. | ||
// TODO yield then await each command response after sending the request. |
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.
I think we'll need to implement something like inspector agent that can automatically track proper ids
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.
Don't need anything particularly fancy for this case, just increment by one per message is fine.
Long term for the REPL etc yeah we'll definitively want a full blown inspector client.
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.
Right, but then you need to receive messages from inspector for each sent message and I believe inspector can send other messages as well which should be ignored.
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.
Right, but then you need to receive messages from inspector for each sent message
The two TODO's tie together somewhat, e.g each socket send will loop awaiting the next response, breaking when a response with the sent id is received then error checking the result.
I believe inspector can send other messages as well which should be ignored.
It can.
Enabling a domain (e.g calling the Runtime.enable method) will enable event notifications for that domain. Events do not carry identifiers however so this doesn't interfere with the above.
Very nice 👍 |
This already gets called later on in execute
So this works, needs to be cleaned up a bit this approach will work. However, it turns out tracefile sections (lcov format) can start with the test name.
And we can't get at the test name since the test runner is implemented in JS; If we were to integrate the coverage collector directly in the test runner on the however we could support this. I think implementing it in JS would be the cleaner implementation in the long run, for one the threading issue just goes away. Other things implemented in JS like the REPL are also in need of an inspector client for things like tab completion so it's somewhat inevitable that we'll end up with an internal inspector client in JS someday. 🤔 |
@caspervonb thanks for detailed description. Inspector client in JS is a desirable feat, but I think we could land this PR only with terminal output for the first pass. Could the report be made a bit more detailed, eg. showing distinct percentages for branches and statements? |
Hmm, I'll clean this up first but it's doable, just have to walk the AST checking if node ranges are inside covered ranges to to calculate that. |
This comment has been minimized.
This comment has been minimized.
@caspervonb could you rebase the branch? I'll look into the problems you described above. |
05b47d7
to
e5cc7ea
Compare
This comment has been minimized.
This comment has been minimized.
9efba46
to
05b47d7
Compare
Agreed; I was considering making the host argument of DenoInspector::new an
Agreed.
Thought I had to thread it initially but turned out to be fine to just let it run on the same thread as the main isolate so this could probably just be a queue. |
e7b06c4
to
5a060e0
Compare
Thanks @bartlomieju for merging things into CoverageCollector which more or less what I had in mind. I think this is good enough to land for 1.4, still things to be desired but I'll follow up on hardening the inspector session and separating inspector web socket server from the inspector along with lcov and json reporters etc for ~1.5 or ~1.6. |
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.
LGTM, thank you @caspervonb this is a massive feature! Looking forward to future iterations and other output formats support.
Where can I see the docs for this feature? |
Thanks a lot! |
This adds a coverage option to the test command which prints a summary report of lines covered to stdout.
Closes #106