From 0e3fe694e05516a4beea626f9be2ccb4dfbf0130 Mon Sep 17 00:00:00 2001 From: Kara Woo Date: Fri, 29 May 2026 14:03:44 -0700 Subject: [PATCH 1/3] fix failing bitbucket test --- tests/testthat/projects/falsy-bitbucket/deps.R | 1 - tests/testthat/projects/skeleton-bitbucket/deps.R | 1 + .../packrat/packrat.lock | 8 ++++---- tests/testthat/test-packrat.R | 11 +++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) delete mode 100644 tests/testthat/projects/falsy-bitbucket/deps.R create mode 100644 tests/testthat/projects/skeleton-bitbucket/deps.R rename tests/testthat/projects/{falsy-bitbucket => skeleton-bitbucket}/packrat/packrat.lock (65%) diff --git a/tests/testthat/projects/falsy-bitbucket/deps.R b/tests/testthat/projects/falsy-bitbucket/deps.R deleted file mode 100644 index 5f76bdc8..00000000 --- a/tests/testthat/projects/falsy-bitbucket/deps.R +++ /dev/null @@ -1 +0,0 @@ -library(falsy) diff --git a/tests/testthat/projects/skeleton-bitbucket/deps.R b/tests/testthat/projects/skeleton-bitbucket/deps.R new file mode 100644 index 00000000..d37a0016 --- /dev/null +++ b/tests/testthat/projects/skeleton-bitbucket/deps.R @@ -0,0 +1 @@ +library(skeleton) diff --git a/tests/testthat/projects/falsy-bitbucket/packrat/packrat.lock b/tests/testthat/projects/skeleton-bitbucket/packrat/packrat.lock similarity index 65% rename from tests/testthat/projects/falsy-bitbucket/packrat/packrat.lock rename to tests/testthat/projects/skeleton-bitbucket/packrat/packrat.lock index 141bccc5..da1bbfd5 100644 --- a/tests/testthat/projects/falsy-bitbucket/packrat/packrat.lock +++ b/tests/testthat/projects/skeleton-bitbucket/packrat/packrat.lock @@ -3,12 +3,12 @@ PackratVersion: 0.5.0.11 RVersion: 3.5.1 Repos: CRAN=https://cran.rstudio.com/ -Package: falsy +Package: skeleton Source: bitbucket Version: 1.0.1 Hash: 97013d7da058d0be0595621449505494 -RemoteRepo: falsy -RemoteUsername: rstudio_official +RemoteRepo: skeleton +RemoteUsername: kevinushey RemoteRef: master -RemoteSha: 26a36cf957a18569e311ef75b6f61f822de945ef +RemoteSha: 958296dbbbf7f1d82f7f5dd1b121c7558604809f RemoteHost: api.bitbucket.org/2.0 diff --git a/tests/testthat/test-packrat.R b/tests/testthat/test-packrat.R index 1ae6be35..caca6395 100644 --- a/tests/testthat/test-packrat.R +++ b/tests/testthat/test-packrat.R @@ -373,13 +373,20 @@ withTestContext({ test_that("Packages restored from BitBucket have RemoteType+RemoteHost in their DESCRIPTION", { skip_on_cran() - projRoot <- cloneTestProject("falsy-bitbucket") + skip_if_offline() + projRoot <- cloneTestProject("skeleton-bitbucket") # ignore R version warnings suppressWarnings(restore(projRoot)) + lib <- libDir(projRoot) + + # verify the package was installed and can be loaded + expect_true(file.exists(file.path(lib, "skeleton"))) + expect_true(requireNamespace("skeleton", lib.loc = lib)) + # validate the installed package has properly annotated DESCRIPTION - descpath <- file.path(libDir(projRoot), "falsy/DESCRIPTION") + descpath <- file.path(lib, "skeleton/DESCRIPTION") desc <- as.data.frame(readDcf(descpath)) expect_true(desc$RemoteType == "bitbucket") expect_true(desc$RemoteHost == "api.bitbucket.org/2.0") From f71bbe91f02f26b8ffd787f51028f10a2b3d1d9d Mon Sep 17 00:00:00 2001 From: Kara Woo Date: Fri, 29 May 2026 14:04:02 -0700 Subject: [PATCH 2/3] add github test and improve gitlab --- tests/testthat/projects/falsy-github/deps.R | 1 + .../falsy-github/packrat/packrat.lock | 18 ++++++++++ tests/testthat/test-packrat.R | 35 ++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/projects/falsy-github/deps.R create mode 100644 tests/testthat/projects/falsy-github/packrat/packrat.lock diff --git a/tests/testthat/projects/falsy-github/deps.R b/tests/testthat/projects/falsy-github/deps.R new file mode 100644 index 00000000..5f76bdc8 --- /dev/null +++ b/tests/testthat/projects/falsy-github/deps.R @@ -0,0 +1 @@ +library(falsy) diff --git a/tests/testthat/projects/falsy-github/packrat/packrat.lock b/tests/testthat/projects/falsy-github/packrat/packrat.lock new file mode 100644 index 00000000..617d26fe --- /dev/null +++ b/tests/testthat/projects/falsy-github/packrat/packrat.lock @@ -0,0 +1,18 @@ +PackratFormat: 1.4 +PackratVersion: 0.5.0.11 +RVersion: 3.5.1 +Repos: CRAN=https://cran.rstudio.com/ + +Package: falsy +Source: github +Version: 1.0.1 +Hash: cd9f70fd26fa58a4b3070370b16b8660 +GithubRepo: falsy +GithubUsername: cran +GithubRef: master +GithubSha1: 26a36cf957a18569e311ef75b6f61f822de945ef +RemoteHost: api.github.com +RemoteRepo: falsy +RemoteUsername: cran +RemoteRef: master +RemoteSha: 26a36cf957a18569e311ef75b6f61f822de945ef diff --git a/tests/testthat/test-packrat.R b/tests/testthat/test-packrat.R index caca6395..6c36c75e 100644 --- a/tests/testthat/test-packrat.R +++ b/tests/testthat/test-packrat.R @@ -354,14 +354,21 @@ withTestContext({ test_that("Packages restored from GitLab have RemoteType+RemoteHost in their DESCRIPTION", { skip_on_cran() + skip_if_offline() skip_on_os("windows") # Windows tar.exe fails to extract the archive received here. projRoot <- cloneTestProject("falsy-gitlab") # ignore R version warnings suppressWarnings(restore(projRoot)) + lib <- libDir(projRoot) + + # verify the package was installed and can be loaded + expect_true(file.exists(file.path(lib, "falsy"))) + expect_true(requireNamespace("falsy", lib.loc = lib)) + # validate the installed package has properly annotated DESCRIPTION - descpath <- file.path(libDir(projRoot), "falsy/DESCRIPTION") + descpath <- file.path(lib, "falsy/DESCRIPTION") desc <- as.data.frame(readDcf(descpath)) expect_true(desc$RemoteType == "gitlab") expect_true(desc$RemoteHost == "gitlab.com") @@ -399,6 +406,32 @@ withTestContext({ expect_false("remote_subdir" %in% names(record)) }) + test_that("Packages restored from GitHub have GithubRepo+GithubSHA1 in their DESCRIPTION", { + skip_on_cran() + skip_if_offline() + projRoot <- cloneTestProject("falsy-github") + + suppressWarnings(restore(projRoot)) + + lib <- libDir(projRoot) + + # verify the package was installed and can be loaded + expect_true(file.exists(file.path(lib, "falsy"))) + expect_true(requireNamespace("falsy", lib.loc = lib)) + + # validate the installed package has properly annotated DESCRIPTION + descpath <- file.path(lib, "falsy/DESCRIPTION") + desc <- as.data.frame(readDcf(descpath)) + expect_equal(desc$RemoteType, "github") + expect_equal(desc$GithubRepo, "falsy") + expect_equal(desc$GithubUsername, "cran") + expect_equal(desc$GithubSHA1, "26a36cf957a18569e311ef75b6f61f822de945ef") + + # confirm that packrat interprets this package as coming from github + record <- inferPackageRecord(desc) + expect_equal(record$source, "github") + }) + test_that("packrat and remotes annotated descriptions are comparable", { remotesDesc <- as.data.frame(readDcf( "resources/descriptions/falsy.remotes" From 17cac38cd40e169026540a54e30ffb20fcd55894 Mon Sep 17 00:00:00 2001 From: Kara Woo Date: Fri, 29 May 2026 14:10:39 -0700 Subject: [PATCH 3/3] cleanup --- tests/testthat/test-packrat.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/test-packrat.R b/tests/testthat/test-packrat.R index 6c36c75e..d3278bfe 100644 --- a/tests/testthat/test-packrat.R +++ b/tests/testthat/test-packrat.R @@ -366,6 +366,7 @@ withTestContext({ # verify the package was installed and can be loaded expect_true(file.exists(file.path(lib, "falsy"))) expect_true(requireNamespace("falsy", lib.loc = lib)) + on.exit(unloadNamespace("falsy"), add = TRUE) # validate the installed package has properly annotated DESCRIPTION descpath <- file.path(lib, "falsy/DESCRIPTION") @@ -391,6 +392,7 @@ withTestContext({ # verify the package was installed and can be loaded expect_true(file.exists(file.path(lib, "skeleton"))) expect_true(requireNamespace("skeleton", lib.loc = lib)) + on.exit(unloadNamespace("skeleton"), add = TRUE) # validate the installed package has properly annotated DESCRIPTION descpath <- file.path(lib, "skeleton/DESCRIPTION") @@ -418,6 +420,7 @@ withTestContext({ # verify the package was installed and can be loaded expect_true(file.exists(file.path(lib, "falsy"))) expect_true(requireNamespace("falsy", lib.loc = lib)) + on.exit(unloadNamespace("falsy"), add = TRUE) # validate the installed package has properly annotated DESCRIPTION descpath <- file.path(lib, "falsy/DESCRIPTION")