From 56af129a9c467070e233c3dbbcc8b759229a4365 Mon Sep 17 00:00:00 2001 From: gfinak Date: Sat, 30 Mar 2019 09:40:30 -0700 Subject: [PATCH] fix tests for both usethis 1.4 and the coming 1.5 --- DESCRIPTION | 4 ++-- R/skeleton.R | 12 +++++++++--- codemeta.json | 3 +-- tests/testthat/test-conditional-build.R | 2 +- tests/testthat/test-document.R | 2 +- tests/testthat/test-edge-cases.R | 2 +- tests/testthat/test-project-path.R | 2 +- tests/testthat/test-r-processing.R | 2 +- tests/testthat/test-skeleton-data-dependencies.R | 2 +- 9 files changed, 18 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5a665fb..35b156a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,7 @@ Authors@R: comment = "Kara reviewed the package for ropensci, see "), person("William", "Landau", role = "rev", comment = "William reviewed the package for ropensci, see ")) -Version: 0.15.6.901 +Version: 0.15.6.902 Description: A framework to help construct R data packages in a reproducible manner. Potentially time consuming processing of raw data sets into analysis ready data sets is done in a reproducible @@ -38,7 +38,7 @@ Imports: stringr, futile.logger, rprojroot, - usethis (>= 1.4.0.900), + usethis, crayon VignetteBuilder: knitr RoxygenNote: 6.1.1 diff --git a/R/skeleton.R b/R/skeleton.R index 1cc74a3..4da92e5 100644 --- a/R/skeleton.R +++ b/R/skeleton.R @@ -55,9 +55,13 @@ datapackage_skeleton <- path = file.path(path, name), rstudio = FALSE, open = FALSE ) - usethis::proj_set(package_path) + # compatibility between usethis 1.4 and 1.5. + if(is.character(package_path)){ + usethis::proj_set(package_path) + }else{ # create the rest of the necessary elements in the package - # package_path <- file.path(path, name) + package_path <- file.path(path, name) + } description <- desc::desc(file = file.path(package_path, "DESCRIPTION")) description$set("DataVersion" = "0.1.0") @@ -196,7 +200,9 @@ datapackage.skeleton <- function(name = NULL, code_files = code_files, r_object_names = r_object_names ) - proj_set(proj_path) + if(is.character(proj_path)){ + usethis::proj_set(proj_path) + } } .done <- function(...) { diff --git a/codemeta.json b/codemeta.json index 1a71d19..1f86658 100644 --- a/codemeta.json +++ b/codemeta.json @@ -10,7 +10,7 @@ "codeRepository": "https://github.com/ropensci/DataPackageR", "issueTracker": "https://github.com/ropensci/DataPackageR/issues", "license": "https://spdx.org/licenses/MIT", - "version": "0.15.6.901", + "version": "0.15.6.902", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", @@ -261,7 +261,6 @@ "@type": "SoftwareApplication", "identifier": "usethis", "name": "usethis", - "version": ">= 1.4.0.900", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", diff --git a/tests/testthat/test-conditional-build.R b/tests/testthat/test-conditional-build.R index 66c6f22..b7228fb 100644 --- a/tests/testthat/test-conditional-build.R +++ b/tests/testthat/test-conditional-build.R @@ -34,5 +34,5 @@ test_that("can add a data item", { force = TRUE ) setwd(tempdir()) - usethis::proj_set(path = NULL) + try(usethis::proj_set(NULL),silent = TRUE) #wrap in try for usethis 1.4 vs 1.5 }) diff --git a/tests/testthat/test-document.R b/tests/testthat/test-document.R index ba35fd7..37d4884 100644 --- a/tests/testthat/test-document.R +++ b/tests/testthat/test-document.R @@ -54,5 +54,5 @@ test_that("documentation is built via document()", { recursive = TRUE, force = TRUE ) - usethis::proj_set(path = NULL) + try(usethis::proj_set(NULL),silent = TRUE) #wrap in try for usethis 1.4 vs 1.5 }) diff --git a/tests/testthat/test-edge-cases.R b/tests/testthat/test-edge-cases.R index 62e4024..c67ce25 100644 --- a/tests/testthat/test-edge-cases.R +++ b/tests/testthat/test-edge-cases.R @@ -261,7 +261,7 @@ test_that("package built in different edge cases", { force = TRUE, recursive = TRUE ) - usethis::proj_set(NULL) + try(usethis::proj_set(NULL),silent = TRUE) #wrap in try for usethis 1.4 vs 1.5 expect_error(DataPackageR:::DataPackageR(file.path(tempdir(), "foo"))) datapackage_skeleton( name = "subsetCars", diff --git a/tests/testthat/test-project-path.R b/tests/testthat/test-project-path.R index 39370cb..77e6995 100644 --- a/tests/testthat/test-project-path.R +++ b/tests/testthat/test-project-path.R @@ -24,5 +24,5 @@ unlink(file.path(tempdir(), "subsetCars"), recursive = TRUE, force = TRUE ) -usethis::proj_set(path = NULL) +try(usethis::proj_set(path = NULL), silent = TRUE) #compatibility between usethis 1.4 and 1.5 diff --git a/tests/testthat/test-r-processing.R b/tests/testthat/test-r-processing.R index 0041a01..ecf72e4 100644 --- a/tests/testthat/test-r-processing.R +++ b/tests/testthat/test-r-processing.R @@ -56,6 +56,6 @@ test_that("R file processing works and creates vignettes", { recursive = TRUE, force = TRUE ) - usethis::proj_set(NULL) + try(usethis::proj_set(NULL),silent = TRUE) #wrap in try for usethis 1.4 vs 1.5 remove.packages("rfiletest",lib = file.path(tempdir(),"lib")) }) diff --git a/tests/testthat/test-skeleton-data-dependencies.R b/tests/testthat/test-skeleton-data-dependencies.R index 0e6cd5a..cab908a 100644 --- a/tests/testthat/test-skeleton-data-dependencies.R +++ b/tests/testthat/test-skeleton-data-dependencies.R @@ -65,5 +65,5 @@ test_that("data, code, and dependencies are moved into place by skeleton", { recursive = TRUE, force = TRUE ) - usethis::proj_set(NULL) + try(usethis::proj_set(NULL),silent = TRUE) #wrap in try for usethis 1.4 vs 1.5 })