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

fixing tests #306

Closed
wants to merge 3 commits into from
Closed

fixing tests #306

wants to merge 3 commits into from

Conversation

b-rodrigues
Copy link
Contributor

No description provided.

@b-rodrigues
Copy link
Contributor Author

using withr seems to be the way to go: it's easy to create local tempdirs that are used by all the underlying functions and it's easy to cleanup. Still need to deal with the following vignettes:

  • using nix inside docker
  • binary cache
  • bleeding edge
  • contributing to nixpkgs

I think we might also want to use it for the functions that write to disk, like hash_url()

@philipp-baumann
Copy link
Collaborator

philipp-baumann commented Sep 19, 2024

using withr seems to be the way to go: it's easy to create local tempdirs that are used by all the underlying functions and it's easy to cleanup. Still need to deal with the following vignettes:

* using nix inside docker

* binary cache

* bleeding edge

* contributing to nixpkgs

I think we might also want to use it for the functions that write to disk, like hash_url()

This really helps with the diagnostics, thanks a lot! i believe we should really not add another dependency, that is already known for depreciations. The solution is as simple as that in base R and we can just use the patterns in withr::local_tempdir() and withr::local_tempfile.

https://github.com/r-lib/withr/blob/d6b7d875a3a352a3667ff106ab29ddb9adc0caa0/R/tempfile.R#L63-L66

For a tempfile, we need to properly write the connection, and then we can just really have an on.exit() hook instead of defer.

con <- file(path, open = "wb", encoding = "native.enc")
on.exit(close(con))

writeLines(enc2utf8(lines), con, useBytes = TRUE)

@philipp-baumann
Copy link
Collaborator

should be all fixed by #308 -> we can close this one

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

Successfully merging this pull request may close these issues.

2 participants