Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove tests that rely on external URLs for CRAN tests (to address CRAN removal) #217

Closed
geneorama opened this issue Aug 24, 2023 · 4 comments

Comments

@geneorama
Copy link
Member

A hopefully temporary measure may be to remove tests that rely on external websites for purposes of getting RSocrata back online more quickly than addressing the underlying issue documented in #213

@geneorama
Copy link
Member Author

In separate conversations with humans and ChatGPT4, I think this is the best route for getting back online the fastest.

I like ChatGPT's breakdown for splitting up the tests, it's the best reasoning I've seen it use with R code yet:

You can structure your tests in a way that allows you to run only certain tests depending on the context (e.g., locally or on a CI system) and to skip tests if certain conditions are not met. Here's a guide to help you organize and control the execution of your tests:

  1. Group Tests by Functionality: Inside the testthat directory, you can create subdirectories or individual test files that group related tests together.

  2. Use skip_on_cran(): If you want certain tests to only run locally and not on CRAN, you can use the skip_on_cran() function at the beginning of those test blocks.

  3. Use Environment Variables: You can also use environment variables to control whether certain tests are run. This would allow you to manually control whether certain groups of tests are executed.

Here's an example of how you might structure your code:

Directory Structure

./tests/
├── testthat
│   ├── test-external
│   │   ├── test-external-api-1.R
│   │   └── test-external-api-2.R
│   └── test-internal
│       ├── test-function-1.R
│       └── test-function-2.R
└── testthat.R

Example Test File with Conditional Skipping

In a test file like test-external-api-1.R, you can use the following code:

# Skip this test on CRAN
skip_on_cran()

# Skip if a certain environment variable is not set
if (Sys.getenv("RUN_EXTERNAL_TESTS") != "true") {
  skip("Skipping external tests")
}

# Your actual tests go here
test_that("External API 1 works", {
  # Test code here
})

Controlling Tests via Environment Variables

You can control whether external tests are run by setting an environment variable before running your tests:

export RUN_EXTERNAL_TESTS=true
R CMD check .

This way, you have fine-grained control over which tests are run in different contexts, and you can easily enable or disable groups of tests. You can also further modularize the tests based on functionality and context, making it easier to maintain and understand the test code.

@geneorama
Copy link
Member Author

geneorama commented Aug 24, 2023

Perhaps this should be a separate issue, but I was going to do the work to get on CRAN in this issue.

The other thing is that I was going to move @tomschenkjr's name to the contributor section. We discussed this privately and we think this makes sense (assuming that Tom wants to remain as a contributor 🙏). I hate that emoji, but it's how I feel so there.

However, that does leave the question of who should be the maintainer. Myself and @nicklucius are the most obvious candidates and I see the key decision points as this:

  • I'm generally the main person responding to CRAN and on the project.
  • @nicklucius has ultimate signoff authority on any changes (even if I'm maintainer).

It's also worth noting that @evejennings has operational authority as my manager. Although she has delegated responsibility for the project to me, she has a critical role in certain aspects of the project with regards to the communication and direction of the package as it fits in with the the strategic planning of our data science practice that she leads.

Either way, I have no intention to change our practice around the protected primary branch, which requires review by a second administrator of RSocrata. So unless that changes, there will always be a duality to the maintenance.

EDIT: updated Tom's name to his @
EDIT2: For reference: https://cran.r-project.org/web/packages/policies.html

@geneorama
Copy link
Member Author

The documentation on skipping tests differs from what ChatGPT suggested, I don't believe including the skip command at the top of a script will be effective, it must be included within the test blocks themselves. https://r-pkgs.org/testing-advanced.html#sec-testing-advanced-skip-on-cran

@geneorama
Copy link
Member Author

I'm going to say this is closed, although it's impossible to know with complete certainty.

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

No branches or pull requests

1 participant