extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
195 stars 28 forks source link

Fix document #193

Closed CGMossa closed 2 years ago

CGMossa commented 2 years ago

This is due to || causing an error with more than 1 conditions in R 4.2.

CGMossa commented 2 years ago

It would be nice if this was reviewed by someone who knows how this is supposed to work. I'll make any changes suggested, of course.

Ilia-Kosenkov commented 2 years ago

Well, these functions were intended to work with scalar input. Perhaps it is better to change how it is invoked when used with R 4.2?

Ilia-Kosenkov commented 2 years ago

Ok I checked the issue, I see that we use pretty_rel_path to process multiple paths. Then it is OK to ensure we can work with a vectorized input. Could you please also add a test similar to the reprex discussed in the issue?

CGMossa commented 2 years ago

I think this is weird to make a test out of, but what do you think of this:

test_that("Running `document` after adding multiple files", {
  skip_on_cran()

  path <- local_package("testPackage")
  rextendr::use_extendr()
  rextendr::document()

  file.create(glue("{path}src/rust/src/a.rs"))
  file.create(glue("{path}src/rust/src/b.rs"))

  rextendr::document()
})
Ilia-Kosenkov commented 2 years ago

Shouldn't we have an expect_*() call for {testthat} to work properly?

CGMossa commented 2 years ago

Yeah, but what should I expect? If an error happens then the test fails. The files are empty so there is no snapshot to be made and compared..

Ilia-Kosenkov commented 2 years ago

According to the {testthat} docs (see the description of parameter regexp), one can write exepct_error(code(), NA) to signal that there should be no error.