Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxincs committed May 31, 2024
1 parent 6ebe441 commit 0cbd897
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assertion/function/trustedfunc/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _cfgTrimSuccs = map[trustedFuncSig]bool{
{
kind: _method,
enclosingRegex: regexp.MustCompile(`^testing.(T|B|F|TB)$`),
funcNameRegex: regexp.MustCompile(`^(FailNow|Skip|Skipf|SkipNow)$`),
funcNameRegex: regexp.MustCompile(`^(FailNow)|(Skip(f|Now)?)$`),
}: true,
}

Expand Down
88 changes: 84 additions & 4 deletions testdata/src/go.uber.org/abnormalflow/abnormalflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"
)

func testDirectDereference(msg string, t *testing.T, tb testing.TB) {
func testDirectDereference(msg string, t *testing.T, b *testing.B, f *testing.F, tb testing.TB) {
var nilable *int
switch msg {
case "print":
Expand Down Expand Up @@ -61,6 +61,21 @@ func testDirectDereference(msg string, t *testing.T, tb testing.TB) {
case "testing.T.Skipf":
t.Skipf("msg")
print(*nilable)
case "testing.B.Fatal":
b.Fatal("foo")
print(*nilable)
case "testing.B.Fatalf":
b.Fatalf("foo")
print(*nilable)
case "testing.B.SkipNow":
b.SkipNow()
print(*nilable)
case "testing.B.Skip":
b.Skip()
print(*nilable)
case "testing.B.Skipf":
b.Skipf("msg")
print(*nilable)
case "testing.TB.Fatal":
tb.Fatal("foo")
print(*nilable)
Expand All @@ -76,6 +91,21 @@ func testDirectDereference(msg string, t *testing.T, tb testing.TB) {
case "testing.TB.Skipf":
tb.Skipf("msg")
print(*nilable)
case "testing.F.Fatal":
f.Fatal("foo")
print(*nilable)
case "testing.F.Fatalf":
f.Fatalf("foo")
print(*nilable)
case "testing.F.SkipNow":
f.SkipNow()
print(*nilable)
case "testing.F.Skip":
f.Skip()
print(*nilable)
case "testing.F.Skipf":
f.Skipf("msg")
print(*nilable)
}
}

Expand All @@ -87,8 +117,8 @@ func errReturn(a bool) (*int, error) {
return nil, errors.New("some error")
}

func testErrReturn(msg string, b bool, t *testing.T, tb testing.TB) {
ptr, err := errReturn(b)
func testErrReturn(msg string, val bool, t *testing.T, b *testing.B, f *testing.F, tb testing.TB) {
ptr, err := errReturn(val)
switch msg {
case "print":
if err != nil {
Expand Down Expand Up @@ -151,6 +181,56 @@ func testErrReturn(msg string, b bool, t *testing.T, tb testing.TB) {
t.Skipf("msg %s", err)
}
print(*ptr)
case "testing.B.Fatal":
if err != nil {
b.Fatal(err)
}
print(*ptr)
case "testing.B.Fatalf":
if err != nil {
b.Fatalf("msg %s", err)
}
print(*ptr)
case "testing.B.SkipNow":
if err != nil {
b.SkipNow()
}
print(*ptr)
case "testing.B.Skip":
if err != nil {
b.Skip(err)
}
print(*ptr)
case "testing.B.Skipf":
if err != nil {
b.Skipf("msg %s", err)
}
print(*ptr)
case "testing.F.Fatal":
if err != nil {
f.Fatal(err)
}
print(*ptr)
case "testing.F.Fatalf":
if err != nil {
f.Fatalf("msg %s", err)
}
print(*ptr)
case "testing.F.SkipNow":
if err != nil {
f.SkipNow()
}
print(*ptr)
case "testing.F.Skip":
if err != nil {
f.Skip(err)
}
print(*ptr)
case "testing.F.Skipf":
if err != nil {
f.Skipf("msg %s", err)
}
print(*ptr)
case "testing.TB.Fatal":
if err != nil {
tb.Fatal(err)
Expand All @@ -177,4 +257,4 @@ func testErrReturn(msg string, b bool, t *testing.T, tb testing.TB) {
}
print(*ptr)
}
}
}

0 comments on commit 0cbd897

Please sign in to comment.