Reporters always write to true stdout#420
Conversation
with update of golden files to show the problem
| warning("append ignored", call. = FALSE) | ||
| } | ||
|
|
||
| cat(..., file = self$out, sep = sep, fill = fill, labels = labels) |
There was a problem hiding this comment.
Rather than having our own clone of cat(), I'd rather have something that's tweaked to make like a bit easier:
cat_line <- function(...) {
cat(..., "\n", sep = "")
}Not sure what to call the version that doesn't add a nl
There was a problem hiding this comment.
I'd like to tackle cat() refactoring in a separate PR, this is already big enough.
Caveat: Not all cat() calls have sep = "" in place, but the integration tests should catch this.
|
This looks like a great approach! |
|
Thanks. From a design perspective it probably should be a mixin (can R6 do it?), or a separate class that is instantiated and used by each interested reporter. |
|
Added NEWS. |
|
Also added cat_tight(), cat_line() and cat_paragraph(). |
| for (i in 1:self$n) { | ||
| if (!is.na(self$contexts[i])) { | ||
| cat("# Context", self$contexts[i], "\n") | ||
| self$cat_line("# Context ", self$contexts[i], " ") |
There was a problem hiding this comment.
@dkesh: I'm reworking output for the TAP reporter. Does it require trailing whitespace, or would it work without them?
There was a problem hiding this comment.
Trailing whitespace isn't required by TAP.
On Tue, Mar 22, 2016 at 6:41 PM Kirill Müller notifications@github.com
wrote:
In R/reporter-tap.R
#420 (comment):for (i in 1:self$n) { if (!is.na(self$contexts[i])) {
cat("# Context", self$contexts[i], "\n")self$cat_line("# Context ", self$contexts[i], " ")@dkesh https://github.com/dkesh: I'm reworking output for the TAP
reporter. Does it require trailing whitespace, or would it work without
them?—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/hadley/testthat/pull/420/files/c1146de2c3ca0d721fb7e3cf3ce3ade9e2a9f81f#r57089060
|
Thanks - this is great 😄 |
Works by memoizing
stdout()on creation, and writing strictly to the memoized connection (and not to the possibly overridden standard output).Adding the functionality to Reporter was easiest, other designs might be better.
Follow-up for #395.
Closes #419 (=contains it).