Skip to content

Commit

Permalink
Minor test lints (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored Jan 17, 2024
1 parent 5986ab6 commit 3eb5a82
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/test-cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ test_that("use_cpp11() creates files/dirs, edits DESCRIPTION and .gitignore", {
expect_proj_dir("src")

ignores <- read_utf8(proj_path("src", ".gitignore"))
expect_true(all(c("*.o", "*.so", "*.dll") %in% ignores))
expect_contains(ignores, c("*.o", "*.so", "*.dll"))

namespace <- read_utf8(proj_path("NAMESPACE"))
expect_true(any(grepl("useDynLib", namespace)))
expect_match(namespace, "useDynLib", all = FALSE)
})

test_that("check_cpp_register_deps is silent if all installed, emits todo if not", {
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-github-actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ test_that("use_github_action() accepts a name", {

yml <- yaml::yaml.load_file(proj_path(".github/workflows/R-CMD-check.yaml"))
expect_identical(yml$name, "R-CMD-check")
expect_identical(names(yml$jobs), "R-CMD-check")
expect_named(yml$jobs, "R-CMD-check")

readme_lines <- read_utf8(proj_path("README.md"))
expect_true(any(grepl("R-CMD-check", readme_lines)))
expect_match(readme_lines, "R-CMD-check", all = FALSE)

# .github has been Rbuildignored
expect_true(is_build_ignored("^\\.github$"))
Expand All @@ -130,17 +130,17 @@ test_that("use_tidy_github_actions() configures the full check and pr commands",

yml <- yaml::yaml.load_file(proj_path(".github/workflows/R-CMD-check.yaml"))
expect_identical(yml$name, "R-CMD-check")
expect_identical(names(yml$jobs), "R-CMD-check")
expect_named(yml$jobs, "R-CMD-check")

size_build_matrix <-
length(yml[["jobs"]][["R-CMD-check"]][["strategy"]][["matrix"]][["config"]])
expect_true(size_build_matrix >= 6) # release, r-devel, 4 previous versions
expect_gte(size_build_matrix, 6) # release, r-devel, 4 previous versions

expect_proj_file(".github/workflows/pkgdown.yaml")
expect_proj_file(".github/workflows/test-coverage.yaml")
expect_proj_file(".github/workflows/pr-commands.yaml")

readme_lines <- read_utf8(proj_path("README.md"))
expect_true(any(grepl("R-CMD-check", readme_lines)))
expect_true(any(grepl("test coverage", readme_lines)))
expect_match(readme_lines, "R-CMD-check", all = FALSE)
expect_match(readme_lines, "test coverage", all = FALSE)
})
8 changes: 4 additions & 4 deletions tests/testthat/test-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test_that("use_dependency() upgrades a dependency", {

expect_message(use_dependency("usethis", "Imports"), "Moving 'usethis'")
expect_match(desc::desc_get("Imports"), "usethis")
expect_false(grepl("usethis", desc::desc_get("Suggests")))
expect_no_match(desc::desc_get("Suggests"), "usethis")
})

## https://github.com/r-lib/usethis/issues/99
Expand All @@ -82,7 +82,7 @@ test_that("use_dependency() declines to downgrade a dependency", {

expect_warning(use_dependency("usethis", "Suggests"), "no change")
expect_match(desc::desc_get("Imports"), "usethis")
expect_false(grepl("usethis", desc::desc_get("Suggests")))
expect_no_match( desc::desc_get("Suggests"), "usethis")
})

test_that("can add LinkingTo dependency if other dependency already exists", {
Expand All @@ -95,7 +95,7 @@ test_that("can add LinkingTo dependency if other dependency already exists", {
)
deps <- proj_deps()
expect_setequal(deps$type, c("Imports", "LinkingTo"))
expect_true(all(deps$package == "rlang"))
expect_setequal(deps$package, "rlang")
})

test_that("use_dependency() does not fall over on 2nd LinkingTo request", {
Expand All @@ -121,6 +121,6 @@ test_that("use_dependency() can level up a LinkingTo dependency", {
expect_snapshot(use_package("rlang"))
deps <- proj_deps()
expect_setequal(deps$type, c("Imports", "LinkingTo"))
expect_true(all(deps$package == "rlang"))
expect_setequal(deps$package, "rlang")
})

3 changes: 2 additions & 1 deletion tests/testthat/test-use_standalone.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ test_that("can import standalone file with dependencies", {

desc <- proj_desc()
imports <- proj_desc()$get_field("Imports")
expect_true(grepl("rlang \\(", imports))
expect_length(imports, 1)
expect_match(imports, "rlang")
})

test_that("can use full github url", {
Expand Down

0 comments on commit 3eb5a82

Please sign in to comment.