Note that I observed this unexpected behavior when compiling on Windows, targeting MSVC.
I have not confirmed the behavior on Windows targeting GNU.
The minimal reproducible example (MRE) here shows the problem even when returning a success status code (0), and while a Rust program will generate a 0 status for programs that return a Result::OK or a (), and a 1 status for programs that return Result::Err, as far as I know, we need to call std::process::exit(...) to return any other status code.
Therefore, any program that requires the ability to return a status other than 0 or 1 may get empty, or worse, incomplete, coverage results when testing coverage under MSVC.
I expected to see this happen: The same result as on Linux and MacOS, and the same result that I get if the call to std::process::exit(0) is removed. In both cases, the basic.profraw file size is greater than 0. In the working cases, the non-empty basic.profraw file can be used with llvm-profdata and llvm-cov tools to generate and view coverage reports.
Here is the expected result on Linux, for example:
This bug does not occur on Linux or MacOS.
Note that I observed this unexpected behavior when compiling on Windows, targeting MSVC.
I have not confirmed the behavior on Windows targeting GNU.
The minimal reproducible example (MRE) here shows the problem even when returning a success status code (
0
), and while a Rust program will generate a0
status for programs that return aResult::OK
or a()
, and a1
status for programs that returnResult::Err
, as far as I know, we need to callstd::process::exit(...)
to return any other status code.Therefore, any program that requires the ability to return a status other than
0
or1
may get empty, or worse, incomplete, coverage results when testing coverage under MSVC.I tried this code:
I expected to see this happen: The same result as on Linux and MacOS, and the same result that I get if the call to
std::process::exit(0)
is removed. In both cases, thebasic.profraw
file size is greater than0
. In the working cases, the non-emptybasic.profraw
file can be used withllvm-profdata
andllvm-cov
tools to generate and view coverage reports.Here is the expected result on Linux, for example:
Instead, this happened: The
basic.profraw
file size is0
(as shown in the example above). LLVM coverage reports show no results.Meta