Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CRAN + interactive = less coverage #597

Closed
helgasoft opened this issue Jan 15, 2025 · 2 comments
Closed

CRAN + interactive = less coverage #597

helgasoft opened this issue Jan 15, 2025 · 2 comments

Comments

@helgasoft
Copy link

Facing a dilemma - pass CRAN tests with less coverage, or fail CRAN and get better coverage.
The problem comes from the interactive() flag. To avoid upsetting CRAN checks, we must "protect" (suppress) a number of tests by enclosing them in if (interactive()) {...}.
I suppose it is impossible to make interactive() TRUE by force.
Is there an alternative to replace it with some environment variable in order to allow those extra tests to run only inside covr::coveralls ?

@olivroy
Copy link
Contributor

olivroy commented Jan 15, 2025

You can look at rlang::is_interactive()

rlang provides rlang::local_interactive(). usethis makes extensive use of it in their tests

@helgasoft
Copy link
Author

@olivroy, thank you for replying. Yes, one could set rlang::is_interactive() through rlang::local_interactive().
The problem is that devtools::test and covr::package_coverage will read the same flag and execute the same tests.

I think I found how to differentiate between the two - using flag Sys.getenv("R_COVR")!=''. This is an environment variable set for covr::package_coverage only. Now we can run more tests for coverage without raising warnings and errors in CRAN checks (devtools::test).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants