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

No coverage from killed subprocesses #235

Open
wucke13 opened this issue Jan 5, 2023 · 5 comments
Open

No coverage from killed subprocesses #235

wucke13 opened this issue Jan 5, 2023 · 5 comments
Labels
C-upstream-bug Category: This is a bug of compiler or dependencies (the fix may require action in the upstream)

Comments

@wucke13
Copy link

wucke13 commented Jan 5, 2023

I have the following setup:

  • a bin crate
  • an integration test that uses https://crates.io/crates/test_bin to call the binary with some arguments, spawning it as a child process
  • the binary is a server, which does not terminate ever on its own
    • thus the integration test kills the server child process, that is after it verified that the server works properly 😏

With this setup, zero coverage is reported. What could be the culprit, and how can I get cargo-llvm-cov to report some coverage out of this setup?

Edit: It turns out I get a sensible coverage report if the process exit()s instead of being killed. Is there any way around this?

@taiki-e
Copy link
Owner

taiki-e commented Jan 6, 2023

This is a compiler bug (or limitation). (Also, even exit() is not handled well by compilers on some platforms: rust-lang/rust#77553)

@taiki-e taiki-e added the C-upstream-bug Category: This is a bug of compiler or dependencies (the fix may require action in the upstream) label Jan 6, 2023
@taiki-e taiki-e changed the title No coverage from subprocesses No coverage from killed subprocesses Jan 6, 2023
@wucke13
Copy link
Author

wucke13 commented Jan 7, 2023

@taiki-e Thank your for the quick response. A note though: rust-lang/rust#77553 mentions something akin

This bug does not occur on Linux or MacOS.

However, I see this on a Linux machine.

@taiki-e
Copy link
Owner

taiki-e commented Jan 7, 2023

rust-lang/rust#77553 is about std::process::exit(), your issue is probably about SIGKILL.

std::process::exit() works on linux and macos, but SIGKILL probably does not work on any platform.

@KaareKristensen
Copy link

If exit is only used in the main function a quick and dirty way of circumventing this issue is to let main return an std::process::ExitCode instead.

@taiki-e
Copy link
Owner

taiki-e commented May 13, 2023

I have found an option that potentially handles this well (#280), but something seems to be missing to actually make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-upstream-bug Category: This is a bug of compiler or dependencies (the fix may require action in the upstream)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants