source(file.path("..", "seed-helpers.R")) # A minimal tarball laid out like R CMD INSTALL --build output. make_tarball <- function( package = "R6", version = "2.6.1", built = "R 4.5.3; ; 2026-09-01 10:00:00 UTC; unix", libs = FALSE ) { root <- tempfile("pkg_") dir.create(file.path(root, package, "R"), recursive = TRUE) fields <- c(Package = package, Version = version) if (!is.na(built)) { fields <- c(fields, Built = built) } write.dcf(t(fields), file.path(root, package, "DESCRIPTION")) writeLines("", file.path(root, package, "R", package)) if (libs) { dir.create(file.path(root, package, "libs")) writeLines("", file.path(root, package, "libs", paste0(package, ".so"))) } tarball <- tempfile(fileext = ".tar.gz") old <- setwd(root) on.exit(setwd(old), add = TRUE) utils::tar(tarball, package, compression = "gzip", tar = "internal") tarball } portable <- function(t) { list(inspected = TRUE, sensitive = FALSE, unsupported = character()) } test_that("seed_verdict accepts a pure-R binary from the target minor", { v <- seed_verdict(make_tarball(), "R6", "2.6.1", "4.5", portable) expect_true(v$seed) expect_identical(v$reason, "seeded") }) test_that("seed_verdict refuses what a fresh build would not publish flat", { verdict <- function(tarball, minor = "4.5", abi = portable) { seed_verdict(tarball, "R6", "2.6.1", minor, abi)$reason } expect_identical(verdict(make_tarball(built = NA)), "source") expect_identical( verdict(make_tarball( built = "R 4.5.3; x86_64-pc-linux-musl; 2026-09-01; unix" )), "compiled" ) expect_identical(verdict(make_tarball(libs = TRUE)), "compiled") expect_identical(verdict(make_tarball(), minor = "4.6"), "r-minor") expect_identical(verdict(make_tarball(version = "2.6.0")), "mismatch") # Unknown is a refusal, as is a verdict that some minor cannot load it. expect_identical( verdict(make_tarball(), abi = function(t) list(inspected = FALSE)), "abi" ) expect_identical( verdict( make_tarball(), abi = function(t) list(inspected = TRUE, sensitive = TRUE) ), "abi" ) junk <- tempfile(fileext = ".tar.gz") writeLines("not a tarball", junk) expect_identical(verdict(junk), "unreadable") }) test_that("seed_candidates keeps only uncopied pure-R binaries in scope", { donor <- c( "R6_2.6.1.tar.gz", "Archive/R6/R6_2.5.1.tar.gz", "curl_7.0.0.tar.gz", "4.6/R6_2.6.1.tar.gz", "glue_1.8.0.tar.gz", "gone_1.0.tar.gz", "done_1.0.tar.gz", "skipme_1.0.tar.gz", "PACKAGES.tar.gz" ) etags <- c("a", "b", "c", "d", "c0ffee", "e", "f", "g", "h") out <- seed_candidates( donor, etags, target_keys = c("done_1.0.tar.gz", "4.6/R6_2.5.1.tar.gz"), release_pkgs = c("R6", "curl", "glue", "done", "skipme"), compiled_pkgs = "curl", cran_md5 = c(glue_1.8.0 = "c0ffee", R6_2.6.1 = "zzz"), exclude = "skipme" ) expect_identical(out$key, c("R6_2.6.1.tar.gz", "Archive/R6/R6_2.5.1.tar.gz")) expect_identical(out$package, c("R6", "R6")) expect_identical(out$version, c("2.6.1", "2.5.1")) }) test_that("seed_candidates copies a version listed twice once, flat first", { out <- seed_candidates( c("Archive/R6/R6_2.6.1.tar.gz", "R6_2.6.1.tar.gz"), c("a", "a"), character(), "R6", character(), character() ) expect_identical(out$key, "R6_2.6.1.tar.gz") }) test_that("parse_built separates the R version from the platform", { b <- parse_built("R 4.5.3; ; 2026-09-01 10:00:00 UTC; unix") expect_identical(b$r_version, "4.5.3") expect_identical(b$platform, "") expect_identical( parse_built("R 4.4.3; aarch64-alpine-linux-musl; 2026; unix")$platform, "aarch64-alpine-linux-musl" ) }) test_that("codename_family groups versions of one distribution", { expect_identical(codename_family("alpine325"), "alpine") expect_identical(codename_family("alpine324"), codename_family("alpine325")) expect_false(identical( codename_family("rhel9"), codename_family("alpine324") )) })