Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia-Kosenkov committed Mar 10, 2024
1 parent 63433f9 commit 91cb138
Showing 1 changed file with 38 additions and 36 deletions.
74 changes: 38 additions & 36 deletions tests/testthat/test-document.R
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# test_that("Running `document` after adding multiple files", {
# skip_if_not_installed("usethis")
# skip_if_not_installed("devtools")
# skip_on_cran()
# skip_if_cargo_bin()
test_that("Running `document` after adding multiple files", {
skip_if_not_installed("usethis")
skip_if_not_installed("devtools")
skip_on_cran()
skip_if_cargo_bin()

# path <- local_package("testPackage")
# use_extendr()
# expect_rextendr_error(rextendr::document(), NA)
path <- local_package("testPackage")
use_extendr()
expect_rextendr_error(rextendr::document(), NA)

# file.create(file.path(path, "src/rust/src/a.rs"))
# file.create(file.path(path, "src/rust/src/b.rs"))
file.create(file.path(path, "src/rust/src/a.rs"))
file.create(file.path(path, "src/rust/src/b.rs"))

# expect_rextendr_error(rextendr::document(), NA)
# })
expect_rextendr_error(rextendr::document(), NA)
})

# test_that("Warn if using older rextendr", {
# skip_if_not_installed("usethis")
# skip_if_not_installed("devtools")
# skip_on_cran()
# skip_if_cargo_bin()
test_that("Warn if using older rextendr", {
skip_if_not_installed("usethis")
skip_if_not_installed("devtools")
skip_on_cran()
skip_if_cargo_bin()

# path <- local_package("futurepkg")
# use_extendr()
# desc::desc_set(`Config/rextendr/version` = "999.999")
path <- local_package("futurepkg")
use_extendr()
desc::desc_set(`Config/rextendr/version` = "999.999")

# expect_message(document(quiet = FALSE), "Installed rextendr is older than the version used with this package")
# })
expect_message(document(quiet = FALSE), "Installed rextendr is older than the version used with this package")
})

# test_that("Update the Config/rextendr/version field in DESCRIPTION file", {
# skip_if_not_installed("usethis")
# skip_if_not_installed("devtools")
# skip_on_cran()
# skip_if_cargo_bin()
test_that("Update the Config/rextendr/version field in DESCRIPTION file", {
skip_if_not_installed("usethis")
skip_if_not_installed("devtools")
skip_on_cran()
skip_if_cargo_bin()

# path <- local_package("oldpkg")
# use_extendr()
# desc::desc_set(`Config/rextendr/version` = "0.1")
path <- local_package("oldpkg")
use_extendr()
desc::desc_set(`Config/rextendr/version` = "0.1")

# expect_message(document(quiet = FALSE), "Setting `Config/rextendr/version` to")
expect_message(document(quiet = FALSE), "Setting `Config/rextendr/version` to")

# version_in_desc <- stringi::stri_trim_both(desc::desc_get("Config/rextendr/version", path)[[1]])
# expect_equal(version_in_desc, as.character(packageVersion("rextendr")))
# })
version_in_desc <- stringi::stri_trim_both(desc::desc_get("Config/rextendr/version", path)[[1]])
expect_equal(version_in_desc, as.character(packageVersion("rextendr")))
})

test_that("document() warns if NAMESPACE file is malformed", {
skip_if_not_installed("usethis")
Expand All @@ -52,6 +52,8 @@ test_that("document() warns if NAMESPACE file is malformed", {
path <- local_package("testPackage")
r"(exportPattern("^[[:alpha:]]+"))" |> brio::write_lines("NAMESPACE")
use_extendr()
rextendr::document()
expect_equal(hello_world(), "Hello world!")
expect_warning(
rextendr::document(),
"The 'NAMESPACE' file does not contain the expected `useDynLib` directive."
)
})

0 comments on commit 91cb138

Please sign in to comment.