precommit icon indicating copy to clipboard operation
precommit copied to clipboard

Exclude testthat snapshots from EOF hook

Open assignUser opened this issue 2 years ago • 5 comments

I had mysterious issues with my snapshots, which turned out to be caused by the eof hook changing the .md files.

This is of course easily solved with exclude: '\.Rd|_snaps/' but should maybe added to the default yaml to avoid this issue from the get go :)

assignUser avatar Feb 08 '22 15:02 assignUser

Thanks. We could do that. But I think it's inherently a {testthat} problem, because it's quite generally accepted that there should be an empty line at EOF. Similar for .Rd files, where I excluded it already. I think we should create issues for both, then exclude it in the template for a transition phase and then remove it later (maybe).

lorenzwalthert avatar Feb 08 '22 16:02 lorenzwalthert

I can't seem to find the problem with {roxygen2} anymore. There is https://github.com/r-lib/roxygen2/issues/593, but neither {styler} nor {precommit} has any file in man/ where the trailing line break is missing. Do you want to post a reprex in r-lib/testthat?

lorenzwalthert avatar Feb 09 '22 12:02 lorenzwalthert

Also note there were some discussions around this recently, maybe see if the problem persists with the dev version of {testthat}? https://github.com/r-lib/testthat/issues/1509

lorenzwalthert avatar Feb 09 '22 12:02 lorenzwalthert

I tested it briefly but it still did not work with the testthat dev version. I will have a look some other day to make sure it's not me/my setup

assignUser avatar Feb 09 '22 14:02 assignUser

Also, I think using exclude: '(\.Rd|^tests/testthat/_snaps/.*\.md)$ is also pretty non-ambiguous (if I got the regex right). Is it always .md?

lorenzwalthert avatar Feb 16 '22 22:02 lorenzwalthert

@assignUser should we exclude: '(\.Rd|^tests/testthat/_snaps/.*\.md)$?

lorenzwalthert avatar Nov 12 '22 17:11 lorenzwalthert

Sounds good :)

assignUser avatar Nov 15 '22 15:11 assignUser

@assignUser any interest in contributing? Otherwise I'd close.

lorenzwalthert avatar Oct 16 '23 16:10 lorenzwalthert

Ah sorry, I missed this. Don't have the bandwidth atm so the close is fine :)

assignUser avatar Jan 12 '24 04:01 assignUser