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

Make tests more isolated. #133

Merged
merged 2 commits into from
Mar 20, 2024
Merged

Make tests more isolated. #133

merged 2 commits into from
Mar 20, 2024

Conversation

plietar
Copy link
Member

@plietar plietar commented Mar 20, 2024

Some tests were calling orderly_run without an envir parameter,
which ends up running the report in the global environment. This
pollutes that namespace and might affect subsequent tests.

One particular issue I was hitting was a test depending on the global
data name from utils, while other tests were defining a global
variable with that (unfortunately very common) name.

I've added a envir = new.env() parameter to all the orderly_run
calls I could find, and changed the test that depended on data to use
the fully qualified name utils::base.

Running the whole test suite now leaves an unmodified global
environment:

ls()
# character(0)
devtools::test()
ls()
# character(0)

plietar added 2 commits March 20, 2024 09:30
Some tests were calling `orderly_run` without an `envir` parameter,
which ends up running the report in the global environment. This
pollutes that namespace and might affect subsequent tests.

One particular issue I was hitting was a test depending on the global
`data` name from `utils`, while other tests were defining a global
variable with that (unfortunately very common) name.

I've added a `envir = new.env()` parameter to all the `orderly_run`
calls I could find, and changed the test that depended on `data` to use
the fully qualified name `utils::base`.

Running the whole test suite now leaves an unmodified global
environment:

```r
ls()
# character(0)
devtools::test()
ls()
# character(0)
```
@plietar plietar requested a review from richfitz March 20, 2024 09:38
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (490391b) to head (0e60e3d).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #133   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           40        40           
  Lines         3628      3671   +43     
=========================================
+ Hits          3628      3671   +43     

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

@plietar plietar merged commit 9222c8f into main Mar 20, 2024
11 checks passed
@plietar plietar deleted the clean-tests branch March 20, 2024 11:42
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

Successfully merging this pull request may close these issues.

2 participants