perf(build-newer-r): skip packages that already have a binary in bulk

Decide the already-built candidates from one listing per slot and one ABI-verdict query instead of a DB connection and several S3 requests per package; anything undecidable still goes through bincraft.
This commit is contained in:
Patrick Schratz 2026-10-23 13:16:33 +00:00
commit c3e95f7c69
No known key found for this signature in database
GPG key ID: 62050D5BC68AB6DC

View file

@ -1,4 +1,5 @@
source(file.path("..", "newer-r-helpers.R"))
source(file.path("..", "rebuild-missing-helpers.R"))
test_that("R constraints respect patch versions, bounds, and missing fields", {
expect_true(r_requirement_satisfied(NA_character_, "4.4.3"))
@ -79,3 +80,70 @@ test_that("R-devel Recommended copies cannot block ordinary CRAN dependencies",
c("arules", "arulesSequences", "indirect")
)
})
candidates <- function() {
data.frame(
Package = c(
"flat_done",
"flat_todo",
"minor_done",
"minor_flat_only",
"unclassified",
"fallback"
),
Version = c("1.0", "1.0", "2.0", "2.0", "3.0", "4.0")
)
}
verdicts <- c(
flat_done_1.0 = FALSE,
flat_todo_1.0 = FALSE,
minor_done_2.0 = TRUE,
minor_flat_only_2.0 = TRUE,
fallback_4.0 = FALSE
)
flat <- c(
flat_done_1.0.tar.gz = "aaa",
minor_flat_only_2.0.tar.gz = "bbb",
unclassified_3.0.tar.gz = "ccc",
fallback_4.0.tar.gz = "c0ffee"
)
minor <- c(minor_done_2.0.tar.gz = "ddd")
md5 <- c(fallback_4.0 = "c0ffee")
test_that("newer_r_outstanding skips only binaries at the routed path", {
expect_identical(
newer_r_outstanding(candidates(), verdicts, flat, minor, md5)$Package,
# flat_todo: absent; minor_flat_only: sensitive, so a flat copy does not
# count; unclassified: no verdict, left to bincraft; fallback: CRAN source
c("flat_todo", "minor_flat_only", "unclassified", "fallback")
)
})
test_that("newer_r_outstanding keeps a route whose slot could not be listed", {
expect_identical(
newer_r_outstanding(candidates(), verdicts, NULL, minor, md5)$Package,
c("flat_done", "flat_todo", "minor_flat_only", "unclassified", "fallback")
)
expect_identical(
newer_r_outstanding(candidates(), verdicts, flat, NULL, md5)$Package,
c("flat_todo", "minor_done", "minor_flat_only", "unclassified", "fallback")
)
})
test_that("newer_r_outstanding without verdicts or listings changes nothing", {
expect_identical(
newer_r_outstanding(candidates(), logical(), flat, minor, md5),
candidates()
)
empty <- stats::setNames(character(), character())
expect_identical(
nrow(newer_r_outstanding(candidates(), verdicts, empty, empty, md5)),
nrow(candidates())
)
expect_identical(
nrow(newer_r_outstanding(candidates()[0L, ], verdicts, flat, minor, md5)),
0L
)
})