This repository has been archived by the owner on Feb 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These produce diagnostic output, as defined by the TAP spec.
On Wed, Jan 04, 2017 at 04:58:28PM -0800, Simon Guest wrote:
These produce diagnostic output, as defined by the TAP spec.
Spec reference [1].
Is it worth checking to ensure that the message/format string contains
no newlines? Or inserting leading ‘#’ and stripping any trailing
newline as needed?
[1]: https://testanything.org/tap-version-13-specification.html#diagnostics
|
OK, that's a good idea. Give me a few minutes ... |
What you have in f9cf6d7 looks good to me, but this still needs a |
e740b6b looks good to me. The only other thing I can think of would be to have func main() {
buf := new(bytes.Buffer)
t1 := tap.New()
t1.Header(4)
t2 := tap.New()
t2.Writer = buf
t2.Header(1)
buf.Reset()
t2.Diagnostic("expecting all to be well")
t1.Ok(buf.String() == "# expecting all to be well\n", "Diagnostic correctly formats a single line")
buf.Reset()
t2.Diagnosticf("here's some perfectly magical output: %d %s 0x%X.", 6, "abracadabra", 28)
t1.Ok(buf.String() == "# here's some perfectly magical output: 6 abracadabra 0x1C.\n", "Diagnosticf correctly formats a single line")
buf.Reset()
t2.Diagnostic("some\nmultiline\ntext\n")
t1.Ok(buf.String() == "# some\n# multiline\n# text\n", "Diagnostic correctly formats multiple lines")
buf.Reset()
t2.Diagnosticf("%d lines\n%s multiline\ntext", 3, "more")
t1.Ok(buf.String() == "# 3 lines\n# more multiline\n# text\n", "Diagnosticf correctly formats multiple lines")
t2.Pass("all good")
} |
Hi, I don't think that's worth the effort, sorry. I hope you will take the pull request anyway. :-) |
On Thu, Jan 05, 2017 at 02:08:05PM -0800, Simon Guest wrote:
Hi, I don't think that's worth the effort, sorry. I hope you will
take the pull request anyway. :-)
I'm just the peanut gallery, not a maintainer ;).
|
mndrix
added a commit
that referenced
this pull request
Jan 5, 2017
To verify the changes in #4, I intentionally broke Diagnostic() by prefixing lines with "!" instead of "#" but the tests still passed. The spec[1] allows a test harness to silently ignore lines it doesn't understand, so that behavior makes sense. Red light green light testing[2] requires that our test be capable of failing if something is broken. This commit adds that by comparing the actual output against our expected output. Hat tip to @wking for suggesting to compare output[3]. 1: http://testanything.org/tap-version-13-specification.html#anything-else 2: http://stackoverflow.com/a/404860/174463 3: #4 (comment)
mndrix
added a commit
that referenced
this pull request
Jan 5, 2017
Now that we have a function to generate diagnostic output, we don't have to construct it manually. See #4
Thanks @tesujimath for the patches. Thanks @wking for the code review. I've merged this branch and made a couple follow-up commits (referenced above). |
You're welcome. Thanks for merging it. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #3.
These produce diagnostic output, as defined by the TAP spec.
I thought it was worth having both, as otherwise my code tends to be littered with fmt.Sprintf() inside t.Diagnostic().