]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/mitchellh/go-testing-interface/testing_go19.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / mitchellh / go-testing-interface / testing_go19.go
1 // +build go1.9
2
3 // NOTE: This is a temporary copy of testing.go for Go 1.9 with the addition
4 // of "Helper" to the T interface. Go 1.9 at the time of typing is in RC
5 // and is set for release shortly. We'll support this on master as the default
6 // as soon as 1.9 is released.
7
8 package testing
9
10 import (
11 "fmt"
12 "log"
13 )
14
15 // T is the interface that mimics the standard library *testing.T.
16 //
17 // In unit tests you can just pass a *testing.T struct. At runtime, outside
18 // of tests, you can pass in a RuntimeT struct from this package.
19 type T interface {
20 Error(args ...interface{})
21 Errorf(format string, args ...interface{})
22 Fail()
23 FailNow()
24 Failed() bool
25 Fatal(args ...interface{})
26 Fatalf(format string, args ...interface{})
27 Log(args ...interface{})
28 Logf(format string, args ...interface{})
29 Name() string
30 Skip(args ...interface{})
31 SkipNow()
32 Skipf(format string, args ...interface{})
33 Skipped() bool
34 Helper()
35 }
36
37 // RuntimeT implements T and can be instantiated and run at runtime to
38 // mimic *testing.T behavior. Unlike *testing.T, this will simply panic
39 // for calls to Fatal. For calls to Error, you'll have to check the errors
40 // list to determine whether to exit yourself.
41 type RuntimeT struct {
42 skipped bool
43 failed bool
44 }
45
46 func (t *RuntimeT) Error(args ...interface{}) {
47 log.Println(fmt.Sprintln(args...))
48 t.Fail()
49 }
50
51 func (t *RuntimeT) Errorf(format string, args ...interface{}) {
52 log.Printf(format, args...)
53 t.Fail()
54 }
55
56 func (t *RuntimeT) Fail() {
57 t.failed = true
58 }
59
60 func (t *RuntimeT) FailNow() {
61 panic("testing.T failed, see logs for output (if any)")
62 }
63
64 func (t *RuntimeT) Failed() bool {
65 return t.failed
66 }
67
68 func (t *RuntimeT) Fatal(args ...interface{}) {
69 log.Print(args...)
70 t.FailNow()
71 }
72
73 func (t *RuntimeT) Fatalf(format string, args ...interface{}) {
74 log.Printf(format, args...)
75 t.FailNow()
76 }
77
78 func (t *RuntimeT) Log(args ...interface{}) {
79 log.Println(fmt.Sprintln(args...))
80 }
81
82 func (t *RuntimeT) Logf(format string, args ...interface{}) {
83 log.Println(fmt.Sprintf(format, args...))
84 }
85
86 func (t *RuntimeT) Name() string {
87 return ""
88 }
89
90 func (t *RuntimeT) Skip(args ...interface{}) {
91 log.Print(args...)
92 t.SkipNow()
93 }
94
95 func (t *RuntimeT) SkipNow() {
96 t.skipped = true
97 }
98
99 func (t *RuntimeT) Skipf(format string, args ...interface{}) {
100 log.Printf(format, args...)
101 t.SkipNow()
102 }
103
104 func (t *RuntimeT) Skipped() bool {
105 return t.skipped
106 }
107
108 func (t *RuntimeT) Helper() {}