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

Code coverage for bun test #3975

Merged
merged 14 commits into from
Aug 6, 2023
Merged

Code coverage for bun test #3975

merged 14 commits into from
Aug 6, 2023

Conversation

Jarred-Sumner
Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner commented Aug 4, 2023

What does this PR do?

This is an extremely WIP PR that lets you see what code ran in bun test.

This adds a new flag --coverage to bun test which enables JavaScriptCore's JSC::ControlFlowProfiler which tracks the positions (byte offsets) of code that was executed and how many times.

The hard part here is not the code coverage, but is source-mapping from these byte offsets to line numbers in the input source file.

I see a couple approaches to solving this:

  1. Store byte ranges in sourcemaps, in addition to lines and columns (expensive!)
  2. JSC::SourceProviderCache maybe??

How did you verify your code works?

Too manually. We need some integration tests for this.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

@Jarred-Sumner 1 files with test failures on linux-x64-baseline:

  • test/js/third_party/prisma/prisma.test.ts

View test output

#9deca0a57b80e87731a42b0ff09646575ea2b8e5

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

@Jarred-Sumner 1 files with test failures on linux-x64:

  • test/js/third_party/prisma/prisma.test.ts

View test output

#9deca0a57b80e87731a42b0ff09646575ea2b8e5

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

@Jarred-Sumner 2 files with test failures on bun-darwin-aarch64:

  • test/js/bun/test/test-test.test.ts
  • test/js/node/dns/node-dns.test.js

View test output

#9deca0a57b80e87731a42b0ff09646575ea2b8e5

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

@Jarred-Sumner 4 files with test failures on bun-darwin-x64-baseline:

  • test/js/bun/spawn/spawn-streaming-stdin.test.ts
  • test/js/bun/sqlite/sqlite.test.js
  • test/js/third_party/webpack/webpack.test.ts
  • test/js/web/timers/setTimeout.test.js

View test output

#9deca0a57b80e87731a42b0ff09646575ea2b8e5

@Jarred-Sumner Jarred-Sumner marked this pull request as ready for review August 6, 2023 12:36
@Jarred-Sumner
Copy link
Collaborator Author

Fixes #2311
Fixes #3158

@Jarred-Sumner Jarred-Sumner merged commit 1462445 into main Aug 6, 2023
@Jarred-Sumner Jarred-Sumner deleted the jarred/code-coverage branch August 6, 2023 13:30
trnxdev pushed a commit to trnxdev/bun that referenced this pull request Aug 9, 2023
* WIP code coverage initial commit

* almost works

* one approach

* Code Coverage

* Update WebKit

* it works but is not yet accurate

* skip double ascii check

* wrapper

* it works but i'm not sure what to do about blocks

* hide blocks for now

* Update ZigSourceProvider.cpp

* Create coverage.md

* Update nav.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
@Electroid Electroid mentioned this pull request Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant