Skip to content

Run the pure R tests on CRAN and check that configuration in CI - #1288

Merged
jgabry merged 2 commits into
v1.0from
cran-tests
Sep 25, 2026
Merged

jgabry merged 2 commits into
v1.0from
cran-tests

Conversation

@jgabry

@jgabry jgabry commented Sep 24, 2026

Copy link
Copy Markdown
Member

Submission Checklist

  • Run unit tests
  • Declare copyright holder and agree to license (see below)

Summary

I asked Claude to generate this summary:

tests/testthat.R skipped the whole suite unless NOT_CRAN was set. Six
test files need no CmdStan at all and four more are pure apart from a few
tests, so this PR lets CRAN run them:

  • tests/testthat.R always calls test_check().
  • Every file that needs CmdStan starts with skip_on_cran(), which skips
    the rest of the file (41 files). The six CmdStan tests inside the four
    mixed files (test-build-info.R, test-cpp-options.R,
    test-example.R, test-knitr.R) skip themselves.
  • A new workflow, "CRAN check", runs R CMD check --as-cran on
    ubuntu-latest with NOT_CRAN unset and no CmdStan installed, so a test
    that forgets its skip fails here instead of on CRAN.

On CRAN this is 441 tests in about five seconds. The make mock does not
help here: it stands in for make and the executable's info call, but
stanc still runs for real, so every mocked compile still needs an
installation. The same configuration passes locally with the home
directory and CMDSTAN pointed away from the local install: 0 failures,
55 skips, 0 warnings, and the check itself reports only the usual
new-submission NOTE.

Vignettes and examples were already CRAN-safe (every vignette evaluates
only under NOT_CRAN, every example is in \dontrun{}), so nothing
changes there.

That check's new-submission NOTE also listed three bookdown.org links in
register_knitr_engine()'s help page that now redirect to pkg.yihui.org.
They point at the new pages now, in the R Markdown vignette too.

Part of #1059.

Copyright and Licensing

Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Jonah Gabry

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses:

tests/testthat.R skipped the whole suite unless NOT_CRAN was set. Six
files need no CmdStan at all (the build record, stan_build_info(),
JSON writing, print_stan_file() and the stanc option handling), and
four more are pure apart from a few tests, so CRAN can run those. The
runner now always calls test_check(), every file that needs CmdStan
starts with skip_on_cran(), and the six CmdStan tests inside the mixed
files skip themselves. On CRAN that is 441 tests in about five
seconds. The make mock is no help here: it stands in for make and the
executable's info call, but stanc still runs for real.

A new workflow, "CRAN check", runs R CMD check --as-cran on
ubuntu-latest with NOT_CRAN unset and no CmdStan installed, so a test
that forgets its skip fails on the PR instead of on CRAN. The same
configuration passes locally with the home directory and the CMDSTAN
variable pointed away from the local installation: 0 failures, 55
skips, no warnings.

That check's new-submission NOTE also listed three bookdown.org links
in register_knitr_engine()'s help page that now redirect to
pkg.yihui.org; they point at the new pages, in the vignette too.

Part of #1059.
@jgabry jgabry added the internal-code Tests, code cleanup, refactoring, or other things not user facing label Sep 24, 2026
jgabry added a commit that referenced this pull request Sep 24, 2026
The file compiles a model, so it needs the skip_on_cran() line every
CmdStan test file gets in #1288; adding it here saves that PR a
follow-up once both are on v1.0.

Part of #925.
@codecov-commenter

codecov-commenter commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v1.0@58de6db). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             v1.0    #1288   +/-   ##
=======================================
  Coverage        ?   93.11%           
=======================================
  Files           ?       19           
  Lines           ?     7316           
  Branches        ?        0           
=======================================
  Hits            ?     6812           
  Misses          ?      504           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

r-lib/actions/setup-r exports NOT_CRAN=true, so the first run of the
workflow evaluated the vignettes and failed when the internals vignette
asked for a CmdStan path. CRAN leaves the variable unset, so the check
step now sets it to false, which the vignettes' EVAL parameter and
skip_on_cran() both read as "on CRAN". Checked locally with rcmdcheck
building the vignettes and no CmdStan visible: 0 errors, 0 warnings.

Building the vignettes also surfaced two URLs the earlier check did
not reach: the qs2 repository moved to qsbase/qs2, and the CRAN
policies link loses its anchor, which R's URL check treats as a
non-canonical CRAN URL.

Part of #1059.
@jgabry
jgabry marked this pull request as ready for review September 24, 2026 19:55
@jgabry
jgabry merged commit 547395f into v1.0 Sep 25, 2026
16 of 17 checks passed
@jgabry
jgabry deleted the cran-tests branch September 25, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal-code Tests, code cleanup, refactoring, or other things not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants