-
Notifications
You must be signed in to change notification settings - Fork 186
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
New meta-level test that roxygen2 has been run #2460
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2460 +/- ##
=======================================
Coverage 98.54% 98.54%
=======================================
Files 126 126
Lines 5721 5721
=======================================
Hits 5638 5638
Misses 83 83 ☔ View full report in Codecov by Sentry. |
Hmm this might be a problem for OS dependent Rd. |
even after #2455? |
Should be fixed by that but a similar problem could occur in the future. |
IMO that will catch some rare (but annoying!) issues, but the current script will catch most issues. Not sure it's worth extra compute resources for the rest. |
How much resources does it cost to run? I'm willing to give it a try (it won't be blocking anyway, so might just be a minor annoyance if encountered). Perhaps output a git diff of old vs. new for changed files to ease debugging? |
different locales is a good idea, that'll have low overhead. setting up different containers/OS was my issue.
I pondered this but figured it'd be pretty clear why it fails (oops, I forgot to document). let me add a one liner anyway. |
Usually, yes. But if and when |
.dev/roxygen_test.R
Outdated
} | ||
cat(sprintf("roxygenize() output differs from saved output for %s.\n", file)) | ||
cat("Here's the Rd2txt() output for what's saved:\n") | ||
Rd2txt(old_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this show macros etc.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the help, the default is the "render"
stage which expands macros:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the raw contents of the Rd file are more helpful since those are the files that are checked in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tools::Rdiff()
will compare the raw contents and show the diff, here's the output when I changed <-
to =
in assignment_linter.Rd
:
34c34
< code_lines <- "1 -> x\n2 ->> y"
---
> code_lines = "1 -> x\n2 ->> y"
.dev/roxygen_test.R
Outdated
cat("Here's the Rd2txt() output for roxygenize():\n") | ||
Rd2txt(new_file) | ||
cat("Here's the tools::Rdiff() comparison of the two files:\n") | ||
tools::Rdiff(old_file, new_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tmp1 <- withr::local_tempfile(lines = c("a", "b"))
tmp2 <- withr::local_tempfile(lines = c("a", "b", "c"))
tools::Rdiff(tmp1, tmp2)
#> files differ in number of lines
Created on 2023-12-19 with reprex v2.0.2
That's not very helpful, either...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's annoying, thanks for checking. Maybe we should use testthat::expect_identical()
to handle giving a summarized diff instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
tmp1 <- withr::local_tempfile(lines = c("a", "b"))
tmp2 <- withr::local_tempfile(lines = c("a", "b", "c"))
cat(capture.output(system2("diff", c("--unified", normalizePath(tmp1), normalizePath(tmp2)))), sep = "\n")
Created on 2023-12-19 with reprex v2.0.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tmp1 <- withr::local_tempfile(lines = c("a", "b")) tmp2 <- withr::local_tempfile(lines = c("a", "b", "c")) tools::Rdiff(tmp1, tmp2) #> files differ in number of linesCreated on 2023-12-19 with reprex v2.0.2
That's not very helpful, either...
Hmm, this truncated the output:
files differ in number of lines:
2a3
> c
Note that tools::Rdiff()
is calling diff
under the hood, just with different options (-bw
vs. your --unified
):
Vs. testthat:
testthat::expect_identical(readLines(tmp1), readLines(tmp2))
> Error: readLines(tmp1) (`actual`) not identical to readLines(tmp2) (`expected`).
`actual`: "a" "b"
`expected`: "a" "b" "c"
(with color if we enable it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, weird. I don't get the output from Rdiff in either my IDE or reprex.
I prefer --unified
because that's basically git diff
, which we're very used to reading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try it by forcing a failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't worry too much about that, unless there is a very simple option for diff to fake this path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more importantly we need to make clear which output comes from which source. handled already at current commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB cli is available if we want prettier messages.
We've been bitten a number of times by some small change to the doc mark-up sneaking through to
main
without beroxygenize()
'd, winding up included in some unrelated PR.This simple workflow should prevent that issue from recurring.