Skip to content

Commit 0fa2830

Browse files
committed
Added Diagnostic and Diagnosticf.
These produce diagnostic output, as defined by the TAP spec.
1 parent 010390e commit 0fa2830

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

util/tap/tap.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,13 @@ func (t *T) Count() int {
111111
func (t *T) AutoPlan() {
112112
t.printf("1..%d\n", t.Count())
113113
}
114+
115+
// Diagnostic generates a diagnostic from the message.
116+
func (t *T) Diagnostic(message string) {
117+
t.printf("# %s\n", message)
118+
}
119+
120+
// Diagnosticf generates a diagnostic from the format string and arguments.
121+
func (t *T) Diagnosticf(format string, a ...interface{}) {
122+
t.printf("# "+format+"\n", a...)
123+
}

util/tap/test/diagnostic/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package main
2+
3+
import "github.com/mndrix/tap-go"
4+
5+
func main() {
6+
t := tap.New()
7+
t.Header(1)
8+
t.Diagnostic("expecting all to be well")
9+
t.Diagnosticf("here's some perfectly magical output: %d %s 0x%X.", 6, "abracadabra", 28)
10+
t.Pass("all good")
11+
}

0 commit comments

Comments
 (0)