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 #6362

Closed
wants to merge 1 commit into from
Closed

Code Coverage #6362

wants to merge 1 commit into from

Conversation

meme
Copy link
Contributor

@meme meme commented Sep 17, 2020

Taking a run at #352.

There are a couple of outstanding questions here:

  1. Do we want to invent our own coverage format and visualizer, or do we want to emit data that is compatible with pre-existing tools? If so, what tool(s) are we integrating with?
  2. How can we dynamically allocate memory in compiler_rt? This is needed for storing encountered program counters while tracking code coverage.
  3. How can we get a mapping from program counter to function names or line numbers? Can we guarantee that Zig tests will be compiled with symbols or DWARF symbols and parse our own binary at runtime during coverage output?

You can find an implementation of ASan's SanitizerCoverage runtime here: https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp. If Zig decides to act similarly to the SanitizerCoverage runtime here, we also need to support disk access in the compiler_rt.


Thoughts on 1)

The LLVM coverage report server (tools/sancov/coverage-report-server.py) generates highlighted HTML from SanitizerCoverage files, but I was imagining more what Go does, e.g.:

$ go test -cover fmt
ok  	fmt	0.060s	coverage: 91.4% of statements

Alternatively we could write out the coverage file:

$ go test . -coverprofile cover.out
ok      example        0.001s  coverage: 100.0% of statements

And then provide a tool for collecting more information:

$ go tool cover -func cover.out
example.go:4:              DoSomething     100.0%
total:                     (statements)    100.0%

The advantage of writing out a coverage file is other members of the Zig community could create external software that takes advantage of Zig coverage files and e.g. produce more graphical representations like stylized HTML output.

- Add runtime scaffold
@meme meme closed this Sep 26, 2020
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