Open sourcefrog opened 6 months ago
Looking at the code, I think the problem is that the environment variable is only read by the FailScenario
constructor, so binaries that just directly have failpoints won't ever fail.
I guess I would have expected that you could just embed fail_point!
and then exercise it interactively or from tests that call the binary, by setting $FAILPOINTS
: at least, the docs somewhat give this impression.
Maybe the macro could lazily load the environment variable? I got the idea that FailScenario
was a convenience for test code.
At least, maybe this could be more clear in the docs. But, perhaps the division of responsibility between them could be reconsidered...
The reason I hit this is that I want to exercise failpoints in code run as a subprocess of a test. I thought setting the variable would do it, but it seems that the code under test needs to do FailScenario::setup
from its main
function for them to have any effect. With that added, my reproduction case passes.
It seems like it would be better to separate
fail_point!
Perhaps I'm doing something wrong, but I have code that looks very similar to the examples, and I can't get it to panic or otherwise respond to failpoints in the environment:
The full code is in https://github.com/sourcefrog/fail-repro
main.rs
isWhen I run this:
In case this was broken by a later Cargo change, I tried it on both 1.76 and 1.63 and they both show the same behavior.
This is on x86_64 Linux.