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

devtools::test() with filter argument creates empty _snaps folder when no snapshots are used #1917

Open
slager opened this issue Dec 26, 2023 · 1 comment

Comments

@slager
Copy link

slager commented Dec 26, 2023

None of my tests use snapshots. The initial state of my testthat directory is that there is no _snaps subdirectory.

When I run devtools::test() I can see that the _snaps folder is created and then removed during the testing process.

When I run devtools::test() with the filter argument to run a subset of tests, the _snaps folder is created but not removed.

To reproduce, clone the latest version of this testthat repo, open testthat.Rproj, and step through the following code:

# setup paths
snaps_path <- file.path('tests', 'testthat', '_snaps')
snaps_backup_path <- file.path('tests', 'testthat', '_snaps_backup')

# backup existing _snaps folder
file.rename(snaps_path, snaps_backup_path)
#[1] TRUE

# _snaps folder doesn't exist now
file.exists(snaps_path)
#[1] FALSE

# these tests contain no snapshots
devtools::test(filter = '^bare$')
#ℹ Testing testthat
#Starting 1 test process
#✔ | F W  S  OK | Context
#✔ |          4 | bare                                                                  
#                                                                                      
#══ Results 
#Duration: 2.3 s
#[ FAIL 0 | WARN 0 | SKIP 0 | PASS 4 ]

# _snaps folder got created
file.exists(snaps_path)
#[1] TRUE

# restore existing _snaps folder
unlink(snaps_path, recursive = TRUE)
file.rename(snaps_backup_path, snaps_path)
#[1] TRUE

See also:

#1180

@hadley
Copy link
Member

hadley commented Oct 22, 2024

Is this causing problems for you?

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

2 participants