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

Reporters always write to true stdout #420

Merged
merged 13 commits into from Mar 23, 2016

Conversation

Projects
None yet
3 participants
@krlmlr
Member

krlmlr commented Mar 22, 2016

Works by memoizing stdout() on creation, and writing strictly to the memoized connection (and not to the possibly overridden standard output).

> std <- stdout(); with_sink(file(), cat("a", file = std))
a

Adding the functionality to Reporter was easiest, other designs might be better.

Follow-up for #395.

Closes #419 (=contains it).

warning("append ignored", call. = FALSE)
}
cat(..., file = self$out, sep = sep, fill = fill, labels = labels)

This comment has been minimized.

@hadley

hadley Mar 22, 2016

Member

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

This comment has been minimized.

@krlmlr

krlmlr Mar 22, 2016

Member

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.

@hadley

This comment has been minimized.

Member

hadley commented Mar 22, 2016

This looks like a great approach!

@krlmlr

This comment has been minimized.

Member

krlmlr commented Mar 22, 2016

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.

Kirill Müller
@krlmlr

This comment has been minimized.

Member

krlmlr commented Mar 22, 2016

Added NEWS.

Kirill Müller added some commits Mar 22, 2016

@krlmlr

This comment has been minimized.

Member

krlmlr commented Mar 22, 2016

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], " ")

This comment has been minimized.

@krlmlr

krlmlr Mar 22, 2016

Member

@dkesh: I'm reworking output for the TAP reporter. Does it require trailing whitespace, or would it work without them?

This comment has been minimized.

@dkesh

dkesh Mar 23, 2016

Contributor

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

@hadley hadley merged commit c1146de into r-lib:master Mar 23, 2016

1 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@hadley

This comment has been minimized.

Member

hadley commented Mar 23, 2016

Thanks - this is great 😄

@krlmlr krlmlr deleted the krlmlr:feature/error-in-message-redir branch Mar 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment