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

Fixes for local testing issues #132

Merged
merged 5 commits into from
Jun 18, 2024
Merged

Fixes for local testing issues #132

merged 5 commits into from
Jun 18, 2024

Conversation

hadley
Copy link
Member

@hadley hadley commented Jun 14, 2024

  • Using the default plot device was causing devtools::test() to create a bunch of plot files in the test directory. I don't think there's any reason to use the default plot device (since that may lead to windows popping up for the user), so we just switch to using pdf(NULL) everywhere
  • There was one test that used dev.new() to start a new device; there I made sure that the new device was always a quiet pdf() device.
  • I also fixed a partial argument match warning that was causing a local test failure for me since I have options(warnPartialMatchArgs = TRUE)

hadley added 3 commits June 14, 2024 16:49
* Using the default plot device was causing `devtools::test()` to create a bunch of plot files in the test directory. I don't think there's any reason to use the default plot device (since that may lead to windows popping up for the user), so we just switch to using `pdf(NULL)` everywhere
* There was one test that used `dev.new()` to start a new device; there I made sure that the new device was always a quiet `pdf()` device.
* I also fixed a partial argument match warning that was causing a local test failure for me since I have `options(warnPartialMatchArgs = TRUE)`
@hadley hadley requested a review from cderv June 14, 2024 21:53
(To ensure that (e.g.) we can compute string widths)
} else dev.new()
# Ensure we have a graphics device available for recording, but choose
# one that's available on all platforms and doesn't write to disk
pdf(file = NULL)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could alternatively use something like devoid::void_dev() but that would add a dependency, and there doesn't appear to be any performance advantage:

x <- rnorm(1e5)
y <- rnorm(1e5)

f <- function(dev) {
  dev()
  plot(x, y)
  dev.off()
}

bench::mark(
  f(devoid::void_dev),
  f(\() pdf(NULL))
)
#> # A tibble: 2 × 3
#> expression                   min   median
#> <bch:expr>              <bch:tm> <bch:tm>
#> 1 f(devoid::void_dev)       10.8ms   11.1ms
#> 2 f(function() pdf(NULL))   10.9ms   11.2ms

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I did not knew about devoid package. Though pdf(file = NULL) seems ok !

@hadley hadley merged commit c750df4 into main Jun 18, 2024
13 checks passed
@hadley hadley deleted the new-device branch June 18, 2024 14:41
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