Skip to content

Commit

Permalink
Fix rtools_needed always returning custom
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerga committed Jul 8, 2020
1 parent b1440fb commit f394fed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pkgbuild (development version)

* `compile_dll()` now supports automatic cpp11 registration if the package links to cpp11.
* `rtools_needed` returns correct version instead of "custom" (@burgerga, #97)

# pkgbuild 1.0.8

Expand Down
11 changes: 6 additions & 5 deletions R/rtools.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ is.rtools <- function(x) inherits(x, "rtools")
#'
#' @keywords internal
#' @export
rtools_needed <- function() {
r_version <- getRversion()
rtools_needed <- function(r_version = getRversion()) {
vi <- version_info
vi$custom <- NULL

for (i in rev(seq_along(version_info))) {
version <- names(version_info)[i]
info <- version_info[[i]]
for (i in rev(seq_along(vi))) {
version <- names(vi)[i]
info <- vi[[i]]
ok <- r_version >= info$version_min && r_version <= info$version_max
if (ok)
return(paste("Rtools", version))
Expand Down
2 changes: 1 addition & 1 deletion man/rtools_needed.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/testthat/test-rtools.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ test_that("has_rtools finds rtools", {
expect_true(rtools_path() != "")
}))
})

test_that("rtools_needed works", {
skip_if_not(is_windows())

# Test only frozen versions
expect_equal(rtools_needed("3.6.3"), "Rtools 3.5")
expect_equal(rtools_needed("2.9"), "Rtools 3.0")
expect_equal(rtools_needed("0.0.0"), "the appropriate version of Rtools")
})

0 comments on commit f394fed

Please sign in to comment.