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

Isolate the test runs and the coverage computations #161

Open
vogr opened this issue Aug 12, 2021 · 0 comments
Open

Isolate the test runs and the coverage computations #161

vogr opened this issue Aug 12, 2021 · 0 comments

Comments

@vogr
Copy link
Collaborator

vogr commented Aug 12, 2021

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

test_generated_file <-  function(test) {
    callr::r(function(x) source(x), args=list(test))
}

would 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):

compute_test_coverage <- function(path, test) {
    code <- sprintf('source("%s")', test)
    callr::r(
         function(path, code) covr::package_coverage(path, type="none", code=code),
         args=list(path=path, code=code)
     )
}
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

1 participant