xd009642 / tarpaulin

A code coverage tool for Rust projects
https://crates.io/crates/cargo-tarpaulin
Apache License 2.0
2.5k stars 180 forks source link

Trace down into launched binaries. #107

Closed xd009642 closed 3 years ago

xd009642 commented 6 years ago

This is a big change and probably quite challenging but here it goes.

Given a test or program that uses a function like Command::spawn() or something like assert-cli which launches a new binary follow that binary down and get coverage of it's code. The steps to do this (as far as I can tell are)

  1. When an exec event comes in identify if the binary is in the target folder (use procfs) if it isn't detach ptrace otherwise:
  2. Run them through test_loader.rs to get a tracemap for them. Merge with existing tracemap (maybe after the next step)
  3. Catch the binary when it's launched and instrument it
  4. Carry on running as normal (but may need a way to distinguish which process a breakpoint belongs to)

This is just an initial impression, it may be missing details or not quite work. It's just a record of my thoughts and feelings regarding an initial approach. It does complicate the run time logic of tarpaulin so may involve a substantial redesign of numerous modules as well!

xd009642 commented 4 years ago

Just updated the above with some recent thoughts after looking into this a bit. I'll look to prototyping something in a smaller example binary first as a proof of concept

xd009642 commented 3 years ago

I've got a prototype of following process exec's on https://github.com/xd009642/tarpaulin/pull/615 if you want to try it out. So far I've just tried it on a very simple toy project so more people testing it is appreciated 😄

Ch00k commented 3 years ago

@xd009642 Thanks so much for looking into this. I got the coverage calculated on my integration tests, that call the executable with process:Command. Here is the codecov report: https://codecov.io/gh/Ch00k/orthanc-cli/tree/d30f584c8494231a3330f30e5afbafef50432046/src

Let me me know if you need me to perform any more specific tests before you can merge the PR.

xd009642 commented 3 years ago

Right I've done some more testing and merged, forks don't work but exec does which I feel is the most important part anyway. I'll close this and tackle any issues as they arise when people upgrade :+1:

xd009642 commented 3 years ago

Following forks covered by this issue https://github.com/xd009642/tarpaulin/issues/616