Skip to content

Commit

Permalink
there is a bug in rcmdcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Nov 16, 2024
1 parent 387d4ff commit 38323f5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 26 deletions.
37 changes: 18 additions & 19 deletions R/cran-compliance.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#' - `vendor_pkgs()` returns a data.frame with two columns `crate` and `version`
#'
#' @examples
#'
#' \dontrun{
#' vendor_pkgs()
#' vendor_pkgs()
#' }
#' @export
vendor_pkgs <- function(path = ".", quiet = FALSE, overwrite = NULL) {
Expand Down Expand Up @@ -125,31 +124,31 @@ vendor_pkgs <- function(path = ".", quiet = FALSE, overwrite = NULL) {


#' CRAN compliant extendr packages
#'
#' R packages developed using extendr are not immediately ready to
#' be published to CRAN. The extendr package template ensures that
#'
#' R packages developed using extendr are not immediately ready to
#' be published to CRAN. The extendr package template ensures that
#' CRAN publication is (farily) painless.
#'
#' @section CRAN requirements:
#'
#' In order to publish a Rust based package on CRAN it must meet certain
#' requirements. These are:
#'
#' @section CRAN requirements:
#'
#' In order to publish a Rust based package on CRAN it must meet certain
#' requirements. These are:
#'
#' - Rust dependencies are vendored
#' - The package is compiled offline
#' - the `DESCRIPTION` file's `SystemRequirements` field contains `Cargo (Rust's package manager), rustc`
#'
#' The extendr templates handle all of this _except_ vendoring dependencies.
#'
#' The extendr templates handle all of this _except_ vendoring dependencies.
#' This must be done prior to publication using [`vendor_pkgs()`].
#'
#'
#' In addition, it is important to make sure that CRAN maintainers
#' are aware that the package they are checking contains Rust code.
#' are aware that the package they are checking contains Rust code.
#' Depending on which and how many crates are used as a dependencies
#' the `vendor.tar.xz` will be larger than a few megabytes. If a
#' built package is larger than 5mbs CRAN may reject the submission.
#'
#' the `vendor.tar.xz` will be larger than a few megabytes. If a
#' built package is larger than 5mbs CRAN may reject the submission.
#'
#' To prevent rejection make a note in your `cran-comments.md` file
#' (create one using [`usethis::use_cran_comments()`]) along the lines of
#' "The package tarball is 6mb because Rust dependencies are vendored within src/rust/vendor.tar.xz which is 5.9mb."
#' "The package tarball is 6mb because Rust dependencies are vendored within src/rust/vendor.tar.xz which is 5.9mb."
#' @name cran
NULL
NULL
2 changes: 1 addition & 1 deletion inst/templates/configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ fi
[ -f src/Makevars ] && rm src/Makevars.win

# Substitute @CRAN_FLAGS@ in Makevars.in with the actual value of $CRAN_FLAGS
sed -e "s|@CRAN_FLAGS@|$CRAN_FLAGS|" src/Makevars.in > src/Makevars
sed -e "s|@CRAN_FLAGS@|$CRAN_FLAGS|" src/Makevars.win.in > src/Makevars.win
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/use_extendr.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
[ -f src/Makevars ] && rm src/Makevars.win
# Substitute @CRAN_FLAGS@ in Makevars.in with the actual value of $CRAN_FLAGS
sed -e "s|@CRAN_FLAGS@|$CRAN_FLAGS|" src/Makevars.in > src/Makevars
sed -e "s|@CRAN_FLAGS@|$CRAN_FLAGS|" src/Makevars.win.in > src/Makevars.win

---

Expand Down
9 changes: 7 additions & 2 deletions tests/testthat/test-cran-compliance.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ test_that("rextendr passes CRAN checks", {
use_extendr()
document()
vendor_pkgs()
res <- rcmdcheck::rcmdcheck(env = c("NOT_CRAN" = ""))

res <- rcmdcheck::rcmdcheck(
env = c("NOT_CRAN" = ""),
args = "--no-manual",
libpath = rev(.libPaths())
)

# --offline flag should be set
expect_true(grepl("--offline", res$install_out))
# -j 2 flag should be set
expect_true(grepl("-j 2", res$install_out))

# "Downloading" should not be present
# "Downloading" should not be present
expect_false(grepl("Downloading", res$install_out))

expect_true(
Expand Down
9 changes: 6 additions & 3 deletions tests/testthat/test-use_extendr.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ test_that("use_extendr() handles R package name, crate name and library name sep
test_that("use_extendr() does not allow invalid rust names", {
skip_if_not_installed("usethis")

path <- local_package("testPackage")
path <- local_package("testPackage")
expect_rextendr_error(use_extendr(crate_name = "22unsupported"))
expect_rextendr_error(use_extendr(lib_name = "@unsupported"))
})
Expand Down Expand Up @@ -205,9 +205,12 @@ test_that("`use_extendr()` passes R CMD check", {
document()

# store results
res <- rcmdcheck::rcmdcheck(env = c("NOT_CRAN"="true"))
res <- rcmdcheck::rcmdcheck(
args = "--no-manual",
libpath = rev(.libPaths())
)

# check the output
# check the output
expect_true(
rlang::is_empty(res$errors) && rlang::is_empty(res$warnings)
)
Expand Down

0 comments on commit 38323f5

Please sign in to comment.