From a825b5dd73abf3e4ef7447833b477a10204bff36 Mon Sep 17 00:00:00 2001 From: vincent Date: Sat, 17 Feb 2024 21:42:19 +0100 Subject: [PATCH] fix : improve check --- inst/dummyfolder/global.R | 4 +-- inst/dummyfolder/server.R | 2 +- inst/dummyfolder/ui.R | 2 +- tests/testthat/test-renv_create2.R | 47 ++++++++++++++++++++++++++++-- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/inst/dummyfolder/global.R b/inst/dummyfolder/global.R index 3625d88..20afa47 100644 --- a/inst/dummyfolder/global.R +++ b/inst/dummyfolder/global.R @@ -1,2 +1,2 @@ -library(dplyr) -library(sudoku) +library(extrapackage) +library(glue) diff --git a/inst/dummyfolder/server.R b/inst/dummyfolder/server.R index e7f349e..c8d22d4 100644 --- a/inst/dummyfolder/server.R +++ b/inst/dummyfolder/server.R @@ -7,7 +7,7 @@ # http://shiny.rstudio.com/ # -library(shiny) +# library(shiny) # Define server logic required to draw a histogram function(input, output, session) { diff --git a/inst/dummyfolder/ui.R b/inst/dummyfolder/ui.R index b3c0539..556d841 100644 --- a/inst/dummyfolder/ui.R +++ b/inst/dummyfolder/ui.R @@ -7,7 +7,7 @@ # http://shiny.rstudio.com/ # -library(shiny) +# library(shiny) # Define UI for application that draws a histogram fluidPage( diff --git a/tests/testthat/test-renv_create2.R b/tests/testthat/test-renv_create2.R index 301da4b..5f38430 100644 --- a/tests/testthat/test-renv_create2.R +++ b/tests/testthat/test-renv_create2.R @@ -13,6 +13,49 @@ file.copy( recursive = TRUE ) dummyfolder <- file.path(tmpdir, "dummyfolder") + + + + + + + +# Create a second dummy package that will be a dependance of dummy +# So that, we are sure it does not exists on CRAN for extra checks +extra_path <- file.path(tmpdir, "dummy.extra") +dir.create(extra_path, recursive = TRUE) +file.copy( + system.file("dummypackage", package = "attachment"), + extra_path, + recursive = TRUE +) +extrapackage <- file.path(extra_path, "extrapackage") +file.rename(file.path(extra_path, "dummypackage"), extrapackage) +# Rename package and remove 'Rcpp' +desc_lines <- readLines(file.path(extrapackage, "DESCRIPTION")) +desc_lines <- gsub("dummypackage", "extrapackage", desc_lines) +desc_lines <- desc_lines[-grep("LinkingTo|Rcpp", desc_lines)] +cat(desc_lines, sep = "\n", file = file.path(extrapackage, "DESCRIPTION")) +# Remove calls to 'dummypackage' and 'Rcpp' +unlink(file.path(extrapackage, "tests"), recursive = TRUE) +# document +# inuse <- search() +att_amend_desc(path = extrapackage) +unloadNamespace("extrapackage") # for windows mainly +# Install package to make it available to {renv} +install.packages(extrapackage, repos = NULL, type = "source") + + + + + + + + + + + + lock_ <- file.path(tmpdir, "my_lock.lock") @@ -42,8 +85,8 @@ renv_content <- getFromNamespace("lockfile", "renv")(my_renv_) test_that("lockfile are correct renv files", { expect_s3_class(renv_content, "renv_lockfile_api") -expect_true("dplyr" %in% names(renv_content$data()$Packages)) -expect_true("sudoku" %in% names(renv_content$data()$Packages)) +expect_true("glue" %in% names(renv_content$data()$Packages)) +expect_true("extrapackage" %in% names(renv_content$data()$Packages)) })