-
Notifications
You must be signed in to change notification settings - Fork 73
Don't write to the test directory during testing #548
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
Conversation
Trees and reference items are copied into a test directory. In certain testing environments, the test directory is not writeable. The only safe location to modify files is within tempdir()
Codecov Report
@@ Coverage Diff @@
## master #548 +/- ##
==========================================
- Coverage 90.64% 90.40% -0.25%
==========================================
Files 47 47
Lines 2171 2179 +8
==========================================
+ Hits 1968 1970 +2
- Misses 203 209 +6
Continue to review full report at Codecov.
|
The reason for the testing system to be implemented in its current form is that we want to leverage I believe there is generally no problem with expecting the test directory to be writable, at least we have never experienced it. Do you have a particular use case in mind? Because in general, I don't think we should change this. |
The test directory not writeable at Google, and the change is one that we need to maintain to keep styler tested with our CI system. (FWIW, the other is that we don't allow changes to the working directory during tests; it's a much harder fix). We do this to because all runtime files are read-only, which is part of ensuring that tests are self-contained. Using I know we've been bombarding you with issues recently (sorry). I don't know if anyone ever shared the context of all of this with you. Google's R community recently adopted the tidyverse style guide: A key factor in that decision was styler, and being able to automatically correct style issues throughout our code base. For the last couple of weeks, we've been doing that, running the package over every R file that we have under version contol. In the future, something akin to a sytler precommit hook will make this automatic. Anway, as far as this change goes, if it really impacts your workflow feel free to drop. Thanks! |
Thanks for the context. Indeed we could use Ok, the rule you mention make sense now. If the tests pass, however, nothing should be written anywhere in the test directory, so I assume you just want to have more informative error messages for these cases. Two things come to mind: Environment variables and R options. We could introduce the R option |
That would work for us. For now, you don't have to worry about informative error messages. We can get around that as long as the tests are executable without modifications. |
With informative error message, I meant that you want to see the testthat output, and not "Error: Directory xxx is not writable" (which I thought was why you need this PR). Ok, so can you adapt your PR to:
I will think about how to document this option (along with other ones we have that are not documented) as well as if we need to emit a message / warning during the test run if the option is set (just to make sure we don't forget about it). Also note that with #538, there will be another problem with the |
Maybe you could add a styler reference? I don't think the styler implementation of the tidyverse style guide would make code less compliant with your style guide. |
That's a great point. I'm on vacation now, but I'll add a reference when I get back. |
We now enforce style automatically. See: r-lib/styler#548 (comment)
Do you still want to have this merged? If yes, can you please adapt according to #548 (comment)? I am happy to merge afterwards. |
Sorry for the delay on this! I added an option for determining this behavior. Thanks! |
Looks good. Can to add a |
Thanks for all of the feedback. You'll see from the commits that I took another pass here.
|
Cool, then should we merge this? I assume you tested everything to be working on Google's system as expected so we don't need another pass? |
Not unless I missed something. Let's merge |
Thanks @michaelquinn32. |
Trees and reference items are copied into a test directory. In certain testing environments, the test directory is not writeable. The only safe location to modify files is within tempdir()