diff --git a/DESCRIPTION b/DESCRIPTION index c907ebf78..2ebaf0648 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: riskassessment Title: A web app designed to interface with the `riskmetric` package -Version: 3.0.0.9012 +Version: 3.0.0.9013 Authors@R: c( person("Aaron", "Clark", role = c("aut", "cre"), email = "aaron.clark@biogen.com"), person("Robert", "Krajcik", role = "aut", email = "robert.krajcik@biogen.com"), @@ -68,7 +68,8 @@ Imports: shinyWidgets, stringr, shinyAce, - sortable + sortable, + archive Suggests: chromote (>= 0.1.1.9001), fontawesome, diff --git a/NAMESPACE b/NAMESPACE index a73fff296..8bbcf33e8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,6 +25,8 @@ importFrom(DT,selectRows) importFrom(DT,styleEqual) importFrom(RSQLite,SQLite) importFrom(RSQLite,sqliteCopyDatabase) +importFrom(archive,archive) +importFrom(archive,archive_read) importFrom(bslib,bs_theme) importFrom(cranlogs,cran_downloads) importFrom(desc,desc_fields) diff --git a/NEWS.md b/NEWS.md index 65f680987..9abcac519 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ * Added dependencies/reverse dependencies card hyperlink (#597) * Added non-shinymanager deployment option (#700) * Added Package Dependencies to Reports (#721) +* Shorten waiting time in code explorer/package explorer by reading tarballs in memory (#707) # riskassessment 3.0.0 diff --git a/R/app_server.R b/R/app_server.R index c72116914..f492d3a7c 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -245,35 +245,25 @@ app_server <- function(input, output, session) { }) create_src_dir <- eventReactive(input$tabs, input$tabs == "Source Explorer") - pkgdir <- reactiveVal() + pkgarchive <- reactiveVal() observe({ req(selected_pkg$name() != "-") req(create_src_dir()) req(file.exists(file.path("tarballs", glue::glue("{selected_pkg$name()}_{selected_pkg$version()}.tar.gz")))) - - src_dir <- file.path("source", selected_pkg$name()) - if (dir.exists(src_dir)) { - pkgdir(src_dir) - } else { - withProgress( - utils::untar(file.path("tarballs", glue::glue("{selected_pkg$name()}_{selected_pkg$version()}.tar.gz")), exdir = "source"), - message = glue::glue("Unpacking {selected_pkg$name()}_{selected_pkg$version()}.tar.gz"), - value = 1 - ) - pkgdir(src_dir) - } + pkgarchive(archive::archive(file.path("tarballs", glue::glue("{selected_pkg$name()}_{selected_pkg$version()}.tar.gz"))) %>% + dplyr::arrange(tolower(path))) }) %>% bindEvent(selected_pkg$name(), create_src_dir()) mod_pkg_explorer_server("pkg_explorer", selected_pkg, - pkgdir = pkgdir, + pkgarchive = pkgarchive, creating_dir = create_src_dir, user = user, credentials = credential_config) mod_code_explorer_server("code_explorer", selected_pkg, - pkgdir = pkgdir, + pkgarchive = pkgarchive, creating_dir = create_src_dir, user = user, credentials = credential_config) diff --git a/R/mod_code_explorer.R b/R/mod_code_explorer.R index 571cd005b..646adac08 100644 --- a/R/mod_code_explorer.R +++ b/R/mod_code_explorer.R @@ -11,14 +11,14 @@ mod_code_explorer_ui <- function(id){ ns <- NS(id) uiOutput(ns("func_explorer_ui")) } - #' code_explorer Server Functions #' #' @noRd #' #' @importFrom tools Rd2HTML #' @importFrom purrr map_dfr -mod_code_explorer_server <- function(id, selected_pkg, pkgdir = reactiveVal(), creating_dir = reactiveVal(TRUE), user, credentials){ +#' @importFrom archive archive_read archive +mod_code_explorer_server <- function(id, selected_pkg, pkgarchive = reactiveVal(), creating_dir = reactiveVal(TRUE), user, credentials){ moduleServer( id, function(input, output, session){ ns <- session$ns @@ -79,14 +79,15 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgdir = reactiveVal(), c } }) - exported_functions <- eventReactive(pkgdir(), { - get_exported_functions(pkgdir()) + exported_functions <- eventReactive(pkgarchive(), { + get_exported_functions(pkg_name = selected_pkg$name(), pkg_version = selected_pkg$version()) }) parse_data <- eventReactive(exported_functions(), { + purrr::map_dfr( c("test", "source"), - ~ get_parse_data(.x, pkgdir(), exported_functions()) + ~ get_parse_data(.x, pkgarchive(), pkg_name = selected_pkg$name(), pkg_version = selected_pkg$version(), exported_functions()) ) }) @@ -96,26 +97,36 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgdir = reactiveVal(), c observeEvent(input$exported_function, { req(input$exported_function) test_files(get_files(input$exported_function, "test", parse_data())) - updateSelectInput(session, "test_files", choices = test_files(), - selected = if (!rlang::is_empty(test_files())) test_files()[1] else NULL) + updateSelectInput(session, "test_files", choices = basename(test_files()), + selected = if (!rlang::is_empty(test_files())) basename(test_files())[1] else NULL) source_files(get_files(input$exported_function, "source", parse_data())) - updateSelectInput(session, "source_files", choices = source_files(), - selected = if (!rlang::is_empty(source_files())) source_files()[1] else NULL) + updateSelectInput(session, "source_files", choices = basename(source_files()), + selected = if (!rlang::is_empty(source_files())) basename(source_files())[1] else NULL) - man_files(get_files(input$exported_function, "man", pkgdir())) - updateSelectInput(session, "man_files", choices = man_files(), - selected = if (!rlang::is_empty(man_files())) man_files()[1] else NULL) + man_files(get_files(input$exported_function, "man", pkgarchive(), pkg_name = selected_pkg$name(), pkg_version = selected_pkg$version())) + updateSelectInput(session, "man_files", choices = basename(man_files()), + selected = if (!rlang::is_empty(man_files())) basename(man_files())[1] else NULL) }) test_code <- reactive({ if (rlang::is_empty(test_files())) return(HTML("No files to display")) req(input$test_files) - fp <- if (file.exists(file.path(pkgdir(), "tests", "testthat.R"))) file.path(pkgdir(), "tests", "testthat", input$test_files) else file.path(pkgdir(), "tests", input$test_files) - lines <- readLines(fp) + if (file.path(glue::glue("{selected_pkg$name()}"),"tests", "testthat.R") %in% pkgarchive()$path ) + { + fp <- file.path(glue::glue("{selected_pkg$name()}"), "tests", "testthat", input$test_files)} + else + { + fp <- file.path(glue::glue("{selected_pkg$name()}"), "tests", input$test_files) + } + con <- archive::archive_read(file.path("tarballs", + glue::glue("{selected_pkg$name()}_{selected_pkg$version()}.tar.gz")), + file = fp) + lines <- readLines(con) + close(con) func_list <- c(input$exported_function, paste0("`", input$exported_function, "`")) highlight_index <- parse_data() %>% - filter(file == input$test_files & func %in% func_list) %>% + filter(stringr::str_ends(file, input$test_files) & func %in% func_list) %>% pull(line) renderCode(lines, highlight_index) }) %>% @@ -124,10 +135,15 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgdir = reactiveVal(), c source_code <- reactive({ if (rlang::is_empty(source_files())) return(HTML("No files to display")) req(input$source_files) - lines <- readLines(file.path(pkgdir(), "R", input$source_files)) + fp <- file.path(glue::glue("{selected_pkg$name()}"), "R", input$source_files) + con <- archive::archive_read(file.path("tarballs", + glue::glue("{selected_pkg$name()}_{selected_pkg$version()}.tar.gz")), + file = fp) + lines <- readLines(con) + close(con) func_list <- c(input$exported_function, paste0("`", input$exported_function, "`")) highlight_index <- parse_data() %>% - filter(file == input$source_files & func %in% func_list) %>% + filter(stringr::str_ends(file, input$source_files) & func %in% func_list) %>% pull(line) renderCode(lines, highlight_index) }) %>% @@ -136,9 +152,15 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgdir = reactiveVal(), c man_page <- reactive({ if (rlang::is_empty(man_files())) return(HTML("No files to display")) req(input$man_files) - out_dir <- tempdir() - tools::Rd2HTML(file.path(pkgdir(), "man", input$man_files), package = c(selected_pkg$name(), selected_pkg$version()), out = file.path(out_dir, "man.html")) - includeHTML(file.path(out_dir, "man.html")) + fp <- file.path(glue::glue("{selected_pkg$name()}"), "man", input$man_files) + con <- archive::archive_read(file.path("tarballs", + glue::glue("{selected_pkg$name()}_{selected_pkg$version()}.tar.gz")), + file = fp) + Rdfile <-tools::parse_Rd(con) + close(con) + HTML(paste0(capture.output(tools::Rd2HTML(Rdfile, + package = c(selected_pkg$name(), + selected_pkg$version()), out = "")), collapse = "\n")) }) %>% bindEvent(input$man_files, input$exported_function, ignoreNULL = FALSE) diff --git a/R/mod_code_explorer_utils.R b/R/mod_code_explorer_utils.R index f45d3e706..f0cbcd6bf 100644 --- a/R/mod_code_explorer_utils.R +++ b/R/mod_code_explorer_utils.R @@ -2,14 +2,19 @@ #' #' Scrapes NAMESPACE for exported functions and returns them as a list #' -#' @param pkgdir The package directory to evaluate +#' @param pkgArchive The package directory to evaluate #' #' @return A character vector of the function names #' #' @noRd -get_exported_functions <- function(pkgdir) { - nsFile <- parse(file.path(pkgdir, "NAMESPACE"), keep.source = FALSE, srcfile = NULL) +get_exported_functions <- function(pkg_name, pkg_version) { + + con <- archive::archive_read(file.path("tarballs", + glue::glue("{pkg_name}_{pkg_version}.tar.gz")), + file = glue::glue("{pkg_name}/NAMESPACE")) + nsFile <- parse(con, keep.source = TRUE) nsexp <- character(); nsimp <- character() + close(con) for (e in nsFile) { switch (as.character(e[[1L]]), export = { @@ -28,7 +33,7 @@ get_exported_functions <- function(pkgdir) { #' Parses the files to determine which contain the function(s) of interest #' #' @param type The type of files to parse -#' @param pkgdir The package directory +#' @param pkgArchive The package directory #' @param funcnames The list of functions to evaluate #' #' @return A `tibble` object containing the type of file, file name, function, @@ -37,17 +42,25 @@ get_exported_functions <- function(pkgdir) { #' @noRd #' #' @importFrom utils getParseData -get_parse_data <- function(type = c("test", "source"), pkgdir, funcnames = NULL) { +get_parse_data <- function(type = c("test", "source"), pkgarchive, pkg_name, pkg_version, funcnames = NULL) { + type <- match.arg(type) dirpath <- switch (type, - test = if (file.exists(file.path(pkgdir, "tests", "testthat.R"))) file.path(pkgdir, "tests", "testthat") else file.path(pkgdir, "tests"), - source = file.path(pkgdir, "R") + test = if (file.path(glue::glue("{pkg_name}"), "tests", "testthat.R") %in% pkgarchive$path ){ + file.path(glue::glue("{pkg_name}"), "tests", "testthat") } + else { file.path(glue::glue("{pkg_name}"),"tests") } + , + source = file.path(glue::glue("{pkg_name}"), "R") ) - filenames <- list.files(dirpath, ".+\\.[R|r]$") + filenames <- na.omit((str_extract(pkgarchive$path,paste0(dirpath, ".+\\.[R|r]$")))) dplyr::bind_rows(lapply(filenames, function(filename) { - d <- parse(file.path(dirpath, filename), keep.source = TRUE) %>% + con <- archive::archive_read(file.path("tarballs", + glue::glue("{pkg_name}_{pkg_version}.tar.gz")), + file = filename) + d <- parse(text = readLines(con), keep.source = TRUE) %>% utils::getParseData() %>% dplyr::filter(token %in% c("SYMBOL_FUNCTION_CALL", "SYMBOL", "SPECIAL", "STR_CONST")) + close(con) d <- d %>% dplyr::mutate( type = type, @@ -104,17 +117,23 @@ get_source_files <- function(funcname, parse_data) { #' Returns the man files from the package directory corresponding to the function of interest #' #' @param funcname The name of the function to evaluate -#' @param pkgdir The package directory +#' @param pkgArchive The package directory #' #' @noRd -get_man_files <- function(funcname, pkgdir) { - man_files <- list.files(file.path(pkgdir, "man"), ".+\\.Rd$") +get_man_files <- function(funcname, pkgarchive, pkg_name, pkg_version) { + + man_files <- na.omit((str_extract(pkgarchive$path, + paste(glue::glue("{pkg_name}"), "man", ".+\\.Rd$", sep ="/")))) funcname_regex <- gsub("([.|()\\^{}+$*?]|\\[|\\])", "\\\\\\1", funcname) %>% gsub(pattern = "`", replacement = "`?") %>% gsub(pattern = "\\%", replacement = "\\\\\\\\\\%") i <- sapply(man_files, function(f) { - s <- readLines(file.path(pkgdir, "man", f)) + con <- archive::archive_read(file.path("tarballs", + glue::glue("{pkg_name}_{pkg_version}.tar.gz")), + file = f) + s <- readLines(con) + close(con) any(grepl(sprintf("name\\{%s\\}|alias\\{%s\\}", funcname_regex, funcname_regex), s)) }) man_files[i] diff --git a/R/mod_pkg_explorer.R b/R/mod_pkg_explorer.R index 050f7f73e..0fa0eb518 100644 --- a/R/mod_pkg_explorer.R +++ b/R/mod_pkg_explorer.R @@ -18,12 +18,13 @@ mod_pkg_explorer_ui <- function(id){ #' @importFrom shinyAce updateAceEditor #' @importFrom utils untar #' @importFrom shinyTree shinyTree renderTree updateTree get_selected +#' @importFrom archive archive_read archive #' #' @noRd mod_pkg_explorer_server <- function(id, selected_pkg, accepted_extensions = c("r", "rmd", "rd", "txt", "md","csv", "tsv", "json", "xml", "yaml", "yml", "dcf", "html", "js", "css", "c", "cpp", "h", "java", "scala", "py", "perl", "sh", "sql"), accepted_filenames = c("DESCRIPTION", "NAMESPACE", "LICENSE", "LICENSE.note", "NEWS", "README", "CHANGES", "MD5"), - pkgdir = reactiveVal(), + pkgarchive = reactiveVal(), creating_dir = reactiveVal(TRUE), user, credentials) { moduleServer( id, function(input, output, session){ @@ -31,7 +32,6 @@ mod_pkg_explorer_server <- function(id, selected_pkg, output$pkg_explorer_ui <- renderUI({ - # Lets the user know that a package needs to be selected. if(identical(selected_pkg$name(), character(0))) { showHelperMessage() @@ -84,8 +84,13 @@ mod_pkg_explorer_server <- function(id, selected_pkg, bindEvent(selected_pkg$name(), creating_dir()) nodes <- reactive({ - req(pkgdir()) - s <- make_nodes(list.files(pkgdir(), recursive = TRUE)) + req(pkgarchive()) + s <- pkgarchive() %>% + filter(size > 0) %>% + filter(grepl("/", path)) %>% + dplyr::pull(path) %>% + make_nodes() %>% + .[[1]] if(!is.null(s[["DESCRIPTION"]])){ attr(s[["DESCRIPTION"]],"stselected") = TRUE } @@ -93,9 +98,10 @@ mod_pkg_explorer_server <- function(id, selected_pkg, f <- names(head(purrr::keep(s, \(x) !is.null(attr(x, "sttype"))), 1)) attr(s[[f]],"stselected") = TRUE } + s }) %>% - bindEvent(pkgdir(), selected_pkg$name()) + bindEvent(pkgarchive (), selected_pkg$name()) output$dirtree <- shinyTree::renderTree(nodes()) @@ -117,7 +123,11 @@ mod_pkg_explorer_server <- function(id, selected_pkg, filename <- basename(filepath) e <- tolower(tools::file_ext(filepath)) if (e %in% accepted_extensions || filename %in% accepted_filenames) { - s <- readLines(file.path(pkgdir(), filepath)) + con <- archive::archive_read(file.path("tarballs", + glue::glue("{selected_pkg$name()}_{selected_pkg$version()}.tar.gz")), + file = glue::glue("{selected_pkg$name()}/{filepath}")) + s <- readLines(con) + close(con) s <- paste(s, collapse = "\n") } else { s <- "file format not supported" diff --git a/renv.lock b/renv.lock index f81d2c6cf..47eaa81cc 100644 --- a/renv.lock +++ b/renv.lock @@ -195,6 +195,21 @@ ], "Hash": "74a64813f17b492da9c6afda6b128e3d" }, + "archive": { + "Package": "archive", + "Version": "1.1.5", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "cli", + "cpp11", + "glue", + "rlang", + "tibble" + ], + "Hash": "ed7b553d0142e37936e924b95c876cfe" + }, "askpass": { "Package": "askpass", "Version": "1.1", diff --git a/tests/testthat/_snaps/pkg_explorer/001.json b/tests/testthat/_snaps/pkg_explorer/001.json index 999fc88e6..7dfbf89ce 100644 --- a/tests/testthat/_snaps/pkg_explorer/001.json +++ b/tests/testthat/_snaps/pkg_explorer/001.json @@ -1,123 +1,6 @@ { "input": { "src_explorer-dirtree": { - "DESCRIPTION": 0, - "LICENSE": 0, - "MD5": 0, - "NAMESPACE": 0, - "NEWS.md": 0, - "R": { - "across.R": 0, - "all-equal.R": 0, - "arrange.R": 0, - "bind-cols.R": 0, - "bind-rows.R": 0, - "by.R": 0, - "case-match.R": 0, - "case-when.R": 0, - "coalesce.R": 0, - "colwise-arrange.R": 0, - "colwise-distinct.R": 0, - "colwise-filter.R": 0, - "colwise-funs.R": 0, - "colwise-group-by.R": 0, - "colwise-mutate.R": 0, - "colwise-select.R": 0, - "colwise.R": 0, - "compat-dbplyr.R": 0, - "compat-name-repair.R": 0, - "compute-collect.R": 0, - "conditions.R": 0, - "consecutive-id.R": 0, - "context.R": 0, - "copy-to.R": 0, - "count-tally.R": 0, - "data-bands.R": 0, - "data-mask.R": 0, - "data-starwars.R": 0, - "data-storms.R": 0, - "dbplyr.R": 0, - "defunct.R": 0, - "deprec-combine.R": 0, - "deprec-context.R": 0, - "deprec-dbi.R": 0, - "deprec-do.R": 0, - "deprec-funs.R": 0, - "deprec-lazyeval.R": 0, - "deprec-src-local.R": 0, - "deprec-tibble.R": 0, - "desc.R": 0, - "distinct.R": 0, - "doc-methods.R": 0, - "doc-params.R": 0, - "dplyr.R": 0, - "error.R": 0, - "explain.R": 0, - "filter.R": 0, - "funs.R": 0, - "generics.R": 0, - "group-by.R": 0, - "group-data.R": 0, - "group-map.R": 0, - "group-nest.R": 0, - "group-split.R": 0, - "group-trim.R": 0, - "grouped-df.R": 0, - "groups-with.R": 0, - "if-else.R": 0, - "import-standalone-lazyeval.R": 0, - "import-standalone-obj-type.R": 0, - "import-standalone-purrr.R": 0, - "import-standalone-types-check.R": 0, - "join-by.R": 0, - "join-cols.R": 0, - "join-common-by.R": 0, - "join-cross.R": 0, - "join-rows.R": 0, - "join.R": 0, - "lead-lag.R": 0, - "locale.R": 0, - "mutate.R": 0, - "n-distinct.R": 0, - "na-if.R": 0, - "near.R": 0, - "nest-by.R": 0, - "nth-value.R": 0, - "order-by.R": 0, - "pick.R": 0, - "progress.R": 0, - "pull.R": 0, - "rank.R": 0, - "recode.R": 0, - "reexport-magrittr.R": 0, - "reexport-pillar.R": 0, - "reexport-tibble.R": 0, - "reframe.R": 0, - "relocate.R": 0, - "rename.R": 0, - "rows.R": 0, - "rowwise.R": 0, - "sample.R": 0, - "select-helpers.R": 0, - "select.R": 0, - "sets.R": 0, - "slice.R": 0, - "src-dbi.R": 0, - "src.R": 0, - "summarise.R": 0, - "tbl.R": 0, - "top-n.R": 0, - "transmute.R": 0, - "ts.R": 0, - "utils-format.R": 0, - "utils-tidy-eval.R": 0, - "utils.R": 0, - "vctrs.R": 0, - "vec-case-match.R": 0, - "vec-case-when.R": 0, - "zzz.R": 0 - }, - "README.md": 0, "build": { "dplyr.pdf": 0, "vignette.rds": 0 @@ -129,37 +12,39 @@ "starwars.rda": 0, "storms.rda": 0 }, + "DESCRIPTION": 0, "inst": { "doc": { + "base.html": 0, "base.R": 0, "base.Rmd": 0, - "base.html": 0, + "colwise.html": 0, "colwise.R": 0, "colwise.Rmd": 0, - "colwise.html": 0, + "dplyr.html": 0, "dplyr.R": 0, "dplyr.Rmd": 0, - "dplyr.html": 0, + "grouping.html": 0, "grouping.R": 0, "grouping.Rmd": 0, - "grouping.html": 0, + "in-packages.html": 0, "in-packages.R": 0, "in-packages.Rmd": 0, - "in-packages.html": 0, + "programming.html": 0, "programming.R": 0, "programming.Rmd": 0, - "programming.html": 0, + "rowwise.html": 0, "rowwise.R": 0, "rowwise.Rmd": 0, - "rowwise.html": 0, + "two-table.html": 0, "two-table.R": 0, "two-table.Rmd": 0, - "two-table.html": 0, + "window-functions.html": 0, "window-functions.R": 0, - "window-functions.Rmd": 0, - "window-functions.html": 0 + "window-functions.Rmd": 0 } }, + "LICENSE": 0, "man": { "across.Rd": 0, "add_rownames.Rd": 0, @@ -295,6 +180,121 @@ "with_groups.Rd": 0, "with_order.Rd": 0 }, + "MD5": 0, + "NAMESPACE": 0, + "NEWS.md": 0, + "R": { + "across.R": 0, + "all-equal.R": 0, + "arrange.R": 0, + "bind-cols.R": 0, + "bind-rows.R": 0, + "by.R": 0, + "case-match.R": 0, + "case-when.R": 0, + "coalesce.R": 0, + "colwise-arrange.R": 0, + "colwise-distinct.R": 0, + "colwise-filter.R": 0, + "colwise-funs.R": 0, + "colwise-group-by.R": 0, + "colwise-mutate.R": 0, + "colwise-select.R": 0, + "colwise.R": 0, + "compat-dbplyr.R": 0, + "compat-name-repair.R": 0, + "compute-collect.R": 0, + "conditions.R": 0, + "consecutive-id.R": 0, + "context.R": 0, + "copy-to.R": 0, + "count-tally.R": 0, + "data-bands.R": 0, + "data-mask.R": 0, + "data-starwars.R": 0, + "data-storms.R": 0, + "dbplyr.R": 0, + "defunct.R": 0, + "deprec-combine.R": 0, + "deprec-context.R": 0, + "deprec-dbi.R": 0, + "deprec-do.R": 0, + "deprec-funs.R": 0, + "deprec-lazyeval.R": 0, + "deprec-src-local.R": 0, + "deprec-tibble.R": 0, + "desc.R": 0, + "distinct.R": 0, + "doc-methods.R": 0, + "doc-params.R": 0, + "dplyr.R": 0, + "error.R": 0, + "explain.R": 0, + "filter.R": 0, + "funs.R": 0, + "generics.R": 0, + "group-by.R": 0, + "group-data.R": 0, + "group-map.R": 0, + "group-nest.R": 0, + "group-split.R": 0, + "group-trim.R": 0, + "grouped-df.R": 0, + "groups-with.R": 0, + "if-else.R": 0, + "import-standalone-lazyeval.R": 0, + "import-standalone-obj-type.R": 0, + "import-standalone-purrr.R": 0, + "import-standalone-types-check.R": 0, + "join-by.R": 0, + "join-cols.R": 0, + "join-common-by.R": 0, + "join-cross.R": 0, + "join-rows.R": 0, + "join.R": 0, + "lead-lag.R": 0, + "locale.R": 0, + "mutate.R": 0, + "n-distinct.R": 0, + "na-if.R": 0, + "near.R": 0, + "nest-by.R": 0, + "nth-value.R": 0, + "order-by.R": 0, + "pick.R": 0, + "progress.R": 0, + "pull.R": 0, + "rank.R": 0, + "recode.R": 0, + "reexport-magrittr.R": 0, + "reexport-pillar.R": 0, + "reexport-tibble.R": 0, + "reframe.R": 0, + "relocate.R": 0, + "rename.R": 0, + "rows.R": 0, + "rowwise.R": 0, + "sample.R": 0, + "select-helpers.R": 0, + "select.R": 0, + "sets.R": 0, + "slice.R": 0, + "src-dbi.R": 0, + "src.R": 0, + "summarise.R": 0, + "tbl.R": 0, + "top-n.R": 0, + "transmute.R": 0, + "ts.R": 0, + "utils-format.R": 0, + "utils-tidy-eval.R": 0, + "utils.R": 0, + "vctrs.R": 0, + "vec-case-match.R": 0, + "vec-case-when.R": 0, + "zzz.R": 0 + }, + "README.md": 0, "src": { "chop.cpp": 0, "dplyr.h": 0, @@ -468,8 +468,8 @@ "vignettes": { "base.Rmd": 0, "colwise.Rmd": 0, - "compatibility.R": 0, "compatibility.html": 0, + "compatibility.R": 0, "dplyr.Rmd": 0, "grouping.Rmd": 0, "in-packages.Rmd": 0, diff --git a/tests/testthat/test-apps/explorer-app/app.R b/tests/testthat/test-apps/explorer-app/app.R index 4f24e157c..edbfdcbee 100644 --- a/tests/testthat/test-apps/explorer-app/app.R +++ b/tests/testthat/test-apps/explorer-app/app.R @@ -19,7 +19,8 @@ server <- function(input, output, server) { shinyOptions(golem_options = list(assessment_db_name = "dplyr.sqlite")) selected_pkg <- list(name = reactiveVal("dplyr"), version = reactiveVal("1.1.2")) - pkgdir <- reactiveVal(file.path("source", "dplyr")) + pkgarchive <- reactiveVal(archive::archive(file.path("tarballs", "dplyr_1.1.2.tar.gz")) |> + dplyr::arrange(tolower(path))) user <- reactiveValues( name = "tester", role = "admin" @@ -27,12 +28,12 @@ server <- function(input, output, server) { credential_config <- riskassessment:::get_db_config("credentials") riskassessment:::mod_pkg_explorer_server("src_explorer", selected_pkg, - pkgdir = pkgdir, + pkgarchive = pkgarchive, user = user, credentials = credential_config) riskassessment:::mod_code_explorer_server("fn_explorer", selected_pkg, - pkgdir = pkgdir, + pkgarchive = pkgarchive, user = user, credentials = credential_config) } diff --git a/tests/testthat/test-code_explorer.R b/tests/testthat/test-code_explorer.R index 84d128e56..6eb11cf17 100644 --- a/tests/testthat/test-code_explorer.R +++ b/tests/testthat/test-code_explorer.R @@ -34,8 +34,7 @@ test_that("pkg_explorer works", { app <- shinytest2::AppDriver$new(test_path("test-apps", "explorer-app")) app$set_inputs(tabs = "fn_expl_tab") - app$wait_for_idle() - + expect_equal( app$get_values(input = paste("fn_explorer", c("exported_function", "file_type"), sep = "-"))$input, list(`fn_explorer-exported_function` = ".data", `fn_explorer-file_type` = "test")