Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from schmichael/b-add-missing-methods
Browse files Browse the repository at this point in the history
Add missing methods and match upstream order
  • Loading branch information
mitchellh authored Oct 4, 2017
2 parents 7bf6f6e + f04b099 commit a61a995
Showing 1 changed file with 44 additions and 16 deletions.
60 changes: 44 additions & 16 deletions testing_go19.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@ import (
type T interface {
Error(args ...interface{})
Errorf(format string, args ...interface{})
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Fail()
FailNow()
Failed() bool
Helper()
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Log(args ...interface{})
Logf(format string, args ...interface{})
Name() string
Skip(args ...interface{})
SkipNow()
Skipf(format string, args ...interface{})
Skipped() bool
Helper()
}

// RuntimeT implements T and can be instantiated and run at runtime to
// mimic *testing.T behavior. Unlike *testing.T, this will simply panic
// for calls to Fatal. For calls to Error, you'll have to check the errors
// list to determine whether to exit yourself.
type RuntimeT struct {
failed bool
skipped bool
failed bool
}

func (t *RuntimeT) Error(args ...interface{}) {
Expand All @@ -43,20 +49,10 @@ func (t *RuntimeT) Error(args ...interface{}) {
}

func (t *RuntimeT) Errorf(format string, args ...interface{}) {
log.Println(fmt.Sprintf(format, args...))
log.Printf(format, args...)
t.Fail()
}

func (t *RuntimeT) Fatal(args ...interface{}) {
log.Println(fmt.Sprintln(args...))
t.FailNow()
}

func (t *RuntimeT) Fatalf(format string, args ...interface{}) {
log.Println(fmt.Sprintf(format, args...))
t.FailNow()
}

func (t *RuntimeT) Fail() {
t.failed = true
}
Expand All @@ -69,7 +65,15 @@ func (t *RuntimeT) Failed() bool {
return t.failed
}

func (t *RuntimeT) Helper() {}
func (t *RuntimeT) Fatal(args ...interface{}) {
log.Print(args...)
t.FailNow()
}

func (t *RuntimeT) Fatalf(format string, args ...interface{}) {
log.Printf(format, args...)
t.FailNow()
}

func (t *RuntimeT) Log(args ...interface{}) {
log.Println(fmt.Sprintln(args...))
Expand All @@ -78,3 +82,27 @@ func (t *RuntimeT) Log(args ...interface{}) {
func (t *RuntimeT) Logf(format string, args ...interface{}) {
log.Println(fmt.Sprintf(format, args...))
}

func (t *RuntimeT) Name() string {
return ""
}

func (t *RuntimeT) Skip(args ...interface{}) {
log.Print(args...)
t.SkipNow()
}

func (t *RuntimeT) SkipNow() {
t.skipped = true
}

func (t *RuntimeT) Skipf(format string, args ...interface{}) {
log.Printf(format, args...)
t.SkipNow()
}

func (t *RuntimeT) Skipped() bool {
return t.skipped
}

func (t *RuntimeT) Helper() {}

0 comments on commit a61a995

Please sign in to comment.