Skip to content

Commit

Permalink
support upper-case engine names (closes #1803)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Jan 31, 2024
1 parent ae73cfc commit f7822b9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# renv (development version)

* Fixed an issue where `renv` could fail to infer dependencies from
R Markdown code chunks using engine 'R' (upper-case) rathern than
'r' (lower-case). (#1803)

* Fixed an issue where `renv` did not report out-of-sync packages when
one or more packages used in the project were not installed. (#1788)

Expand Down
4 changes: 2 additions & 2 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ renv_dependencies_discover_chunks_ignore <- function(chunk) {

# skip non-R chunks
engine <- chunk$params[["engine"]]
ok <- is.character(engine) && engine %in% c("r", "rscript")
ok <- is.character(engine) && tolower(engine) %in% c("r", "rscript")
if (!ok)
return(TRUE)

Expand Down Expand Up @@ -905,7 +905,7 @@ renv_dependencies_discover_chunks <- function(path, mode) {
if (mode %in% "qmd") {
for (chunk in chunks) {
engine <- chunk$params[["engine"]]
if (is.character(engine) && engine %in% c("r", "rscript")) {
if (is.character(engine) && tolower(engine) %in% c("r", "rscript")) {
qdeps <- renv_dependencies_list(path, "rmarkdown")
break
}
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,18 @@ test_that("dependencies() can parse NAMESPACE files", {
expect_setequal(deps$Package, c("graphics", "tools", "utils"))

})

test_that("dependencies() handles upper-case engine names", {

document <- heredoc("
```{R}
library(A)
```
")

file <- renv_scope_tempfile(fileext = ".Rmd")
writeLines(document, con = file)
deps <- dependencies(file, quiet = TRUE)
expect_true("A" %in% deps$Package)

})

0 comments on commit f7822b9

Please sign in to comment.