tests/testthat/test-goodpractice.R

test_all <- (identical (Sys.getenv ("RRT_TEST_ALL"), "true") ||
    identical (Sys.getenv ("GITHUB_JOB"), "test-coverage") ||
    identical (Sys.getenv ("GITHUB_JOB"), "pkgcheck"))

skip_if (!test_all)

test_that ("goodpractice", {

    checks <- make_check_data_srr_internal (
        goodpractice = TRUE, cleanup = FALSE
    )

    gp <- summarise_gp_checks (checks)
    expect_type (gp, "list")
    expect_length (gp, 2L)
    expect_named (gp, c ("rcmd_errs", "rcmd_warns"))

    md <- gp_checks_to_md (checks)
    expect_type (md, "character")
    expect_gt (length (md), 10L)
    expect_true (any (grepl ("`goodpractice` results", md)))
    expect_true (any (grepl ("Cyclocomplexity", md)))
    expect_true (any (grepl ("Other goodpractice checks", md, fixed = TRUE)))
    fails <- grep ("\\:heavy\\_multiplication\\_x\\:", md)
    expect_true (length (fails) > 2)

    checks$goodpractice$rcmdcheck <- try (stop ("nope"), silent = TRUE)
    gp <- summarise_gp_checks (checks)
    expect_null (gp$rcmd_warns)
    expect_true (grepl ("R CMD check process failed", gp$rcmd_errs))

    fs::dir_delete (checks$pkg$path)
})

Try the pkgcheck package in your browser

Any scripts or data that you put into this service are public.

pkgcheck documentation built on Oct. 13, 2026, 5:06 p.m.