diff --git a/local/r-minor-helpers.R b/local/r-minor-helpers.R new file mode 100644 index 0000000..ffe56fb --- /dev/null +++ b/local/r-minor-helpers.R @@ -0,0 +1,22 @@ +# Metadata-only ABI triage so the full build avoids downloading every source. +# Mirrors bincraft::abi_classify rules 1-2; "ambiguous" packages still need a +# source grep via bincraft::needs_per_minor_recompile(). + +classify_from_metadata <- function(needs_compilation, linking_to, risky_deps) { + nc <- if (length(needs_compilation) == 0L || is.na(needs_compilation)) { + "" + } else { + tolower(trimws(needs_compilation)) + } + if (!identical(nc, "yes")) { + return("not-sensitive") + } + lt <- if (length(linking_to) == 0L || is.na(linking_to)) "" else linking_to + linked <- trimws(unlist(strsplit(lt, "[,\n]"))) + linked <- sub("\\s*\\(.*\\)$", "", linked) # strip "(>= x)" constraints + linked <- linked[nzchar(linked)] + if (any(linked %in% risky_deps)) { + return("sensitive") + } + "ambiguous" +} diff --git a/local/tests/test-r-minor-helpers.R b/local/tests/test-r-minor-helpers.R new file mode 100644 index 0000000..d68e99b --- /dev/null +++ b/local/tests/test-r-minor-helpers.R @@ -0,0 +1,16 @@ +source(file.path("..", "r-minor-helpers.R")) + +test_that("pure-r (NeedsCompilation != yes) is not sensitive", { + expect_identical(classify_from_metadata("no", NA, c("Rcpp")), "not-sensitive") + expect_identical(classify_from_metadata("", "Rcpp", c("Rcpp")), "not-sensitive") +}) + +test_that("LinkingTo a risky dep is sensitive (version constraints stripped)", { + expect_identical(classify_from_metadata("yes", "Rcpp (>= 1.0)", c("Rcpp")), "sensitive") + expect_identical(classify_from_metadata("yes", "R6,\n cpp11", c("Rcpp", "cpp11")), "sensitive") +}) + +test_that("compiled but no risky LinkingTo is ambiguous (needs source)", { + expect_identical(classify_from_metadata("yes", "R6", c("Rcpp", "cpp11")), "ambiguous") + expect_identical(classify_from_metadata("yes", NA, c("Rcpp")), "ambiguous") +})