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

Coverage data not generated on Windows when using libtest_mimic::Conclusion::exit #39

Closed
zaneduffield opened this issue Apr 9, 2024 · 2 comments

Comments

@zaneduffield
Copy link

In nextest-rs/datatest-stable#20 I discovered that coverage data was not being generated for some of my tests. I came to the conclusion (at nextest-rs/datatest-stable#20 (comment)) that the problem was the use of std::process::exit from within libtest_mimic.

It seems that on Windows (but not linux), coverage data isn't written to disk when the process is terminated with std::process::exit. The documentation on which says

Note that because this function never returns, and that it terminates the process, no destructors on the current stack or any other thread's stack will be run.

I presume that the profiling data is written to disk in the destructor for some type, and that isn't run when you terminate abruptly with std::process::terminate. I have no idea why this only affects Windows.

To work around this problem, in datatest-stable the maintainer used libtest_mimic::Conclusion::has_failed to return a std::process::ExitCode from the generated main function (see nextest-rs/datatest-stable@33d4725).
When ExitCode is returned from main, threads are cleaned up and coverage data is generated properly.

As discussed in nextest-rs/datatest-stable#20 (comment) libtest-mimic may want to deprecate libtest_mimic::Conclusion::exit in favour of a method that returns an ExitCode.

@LukasKalbertodt
Copy link
Owner

Thanks for the report. Fixed in the linked commit and released as 0.7.1.

I added exit_code but decided against a full deprecation of the exit methods. I did add a warning to the docs though and moved them to the very bottom.

@zaneduffield
Copy link
Author

That was fast! Thanks 😄

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

No branches or pull requests

2 participants