Skip to content

Commit

Permalink
test(path): Optimize unit test execution results (#3883)
Browse files Browse the repository at this point in the history
* test(path): Add a GC recycle validation

* test(path): Optimize unit test execution results

* test(path): Optimize unit test execution results
  • Loading branch information
flc1125 authored Mar 14, 2024
1 parent ee70b30 commit fd60a24
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package gin

import (
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -80,6 +81,10 @@ func TestPathCleanMallocs(t *testing.T) {
t.Skip("skipping malloc count in short mode")
}

if runtime.GOMAXPROCS(0) > 1 {

This comment has been minimized.

Copy link
@a-h

a-h Mar 15, 2024

I'd expect GOMAXPROCS to almost always be greater than zero, since modern computers are multi-core, and GOMAXPROCS is set to the number of system cores by default.

Is this commit designed to bypass the flaky test? If so, might as well just delete it?

This comment has been minimized.

Copy link
@a-h

a-h Mar 15, 2024

I haven't been able to reproduce the flaky test issue, but I was thinking that it was to do with the float conversion and that this might be the fix.

-               assert.EqualValues(t, allocs, 0)
+               assert.InDelta(t, 0, allocs, 0.1, "cleanPath(%q)", test.result)
t.Skip("skipping malloc count; GOMAXPROCS>1")
}

for _, test := range cleanTests {
allocs := testing.AllocsPerRun(100, func() { cleanPath(test.result) })
assert.EqualValues(t, allocs, 0)
Expand Down

0 comments on commit fd60a24

Please sign in to comment.