Running the tests in isolation would prevent state related issues. The package callr might be useful here (very similar functionality compared to your run_r_fun function, but it passes back the return value and propagates errors) . Something along the lines of
I'm not sure I understand perfectly how the coverage mechanism works currently. In any case, covr would need to be loaded in the subprocess. Something like this would work for one file (not dealing with the ext file or with testthat):
Running the tests in isolation would prevent state related issues. The package
callr
might be useful here (very similar functionality compared to yourrun_r_fun
function, but it passes back the return value and propagates errors) . Something along the lines ofwould work .
I'm not sure I understand perfectly how the coverage mechanism works currently. In any case,
covr
would need to be loaded in the subprocess. Something like this would work for one file (not dealing with the ext file or with testthat):