Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/test: t.Fatal should be called from g running the test or benchmark func #505

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ast/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ func TestGC_Encode(t *testing.T) {
defer wg.Done()
root, err := NewSearcher(_TwitterJson).GetByPath()
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
root.Load()
_, err = root.MarshalJSON()
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
runtime.GC()
}(wg)
Expand Down Expand Up @@ -228,4 +230,4 @@ func TestEncodeNone(t *testing.T) {
out, err = n.MarshalJSON()
require.NoError(t, err)
require.Equal(t, `[null]`, string(out))
}
}
5 changes: 3 additions & 2 deletions ast/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func TestGC_Parse(t *testing.T) {
defer wg.Done()
_, _, err := Loads(_TwitterJson)
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
runtime.GC()
}(wg)
Expand Down Expand Up @@ -351,4 +352,4 @@ func BenchmarkParseSeven_Parallel_Sonic(b *testing.B) {
}
}
})
}
}
5 changes: 3 additions & 2 deletions ast/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func TestGC_Search(t *testing.T) {
defer wg.Done()
_, err := NewSearcher(_TwitterJson).GetByPath("statuses", 0, "id")
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
runtime.GC()
}(wg)
Expand Down Expand Up @@ -408,4 +409,4 @@ func BenchmarkSetOne_Parallel_Sonic(b *testing.B) {
_, _ = node.Set("id", n)
}
})
}
}
6 changes: 4 additions & 2 deletions decoder/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ func TestGC(t *testing.T) {
var w interface{}
out, err := decode(TwitterJson, &w, true)
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
if out != len(TwitterJson) {
t.Fatal(out)
t.Error(out)
return
}
runtime.GC()
}(wg)
Expand Down
8 changes: 5 additions & 3 deletions encoder/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ func TestGC(t *testing.T) {
defer wg.Done()
out, err := Encode(_GenericValue, 0)
if err != nil {
t.Fatal(err)
t.Error(err)
return
}
if len(out) != size {
t.Fatal(len(out), size)
t.Error(len(out), size)
return
}
runtime.GC()
}(wg, n)
Expand Down Expand Up @@ -543,4 +545,4 @@ func BenchmarkEncode_Float32(b *testing.B) {
b.Run(name, lib.test)
}
}
}
}
Loading