test(path): Optimize unit test execution results (#3883)

* test(path): Add a GC recycle validation

* test(path): Optimize unit test execution results

* test(path): Optimize unit test execution results
This commit is contained in:
Flc゛ 2024-03-14 11:22:54 +08:00 committed by GitHub
parent ee70b30a97
commit fd60a24ab7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,7 @@
package gin package gin
import ( import (
"runtime"
"strings" "strings"
"testing" "testing"
@ -80,6 +81,10 @@ func TestPathCleanMallocs(t *testing.T) {
t.Skip("skipping malloc count in short mode") t.Skip("skipping malloc count in short mode")
} }
if runtime.GOMAXPROCS(0) > 1 {
t.Skip("skipping malloc count; GOMAXPROCS>1")
}
for _, test := range cleanTests { for _, test := range cleanTests {
allocs := testing.AllocsPerRun(100, func() { cleanPath(test.result) }) allocs := testing.AllocsPerRun(100, func() { cleanPath(test.result) })
assert.EqualValues(t, allocs, 0) assert.EqualValues(t, allocs, 0)