Skip to content

Commit 36a2c6f

Browse files
committed
fix(testing): remove codspeed folder used for integration tests
1 parent 5331397 commit 36a2c6f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

testing/testing/benchmark.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ func (s *benchState) processBench(b *B) {
955955

956956
file, _ := fn.FileLine(pc)
957957
if strings.HasSuffix(file, "_codspeed.go") {
958-
benchFile = file
958+
benchFile = removeFolderFromPath(file, "codspeed")
959959
}
960960
}
961961

testing/testing/codspeed.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"strings"
89
)
910

1011
type GoRunnerMetadata struct {
@@ -87,3 +88,16 @@ func (b *B) AddBenchmarkMarkers(endTimestamp uint64) {
8788
// Reset to prevent accidental reuse
8889
b.startTimestamp = 0
8990
}
91+
92+
func removeFolderFromPath(path string, folder string) string {
93+
parts := strings.Split(path, string(os.PathSeparator))
94+
95+
var newParts []string
96+
for _, p := range parts {
97+
if p != folder {
98+
newParts = append(newParts, p)
99+
}
100+
}
101+
102+
return filepath.Join(newParts...)
103+
}

testing/testing/testing.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ func (c *common) callSite(skip int) string {
10771077
// Replace _codspeed.go with _test.go for better user experience
10781078
if strings.HasSuffix(file, "_codspeed.go") {
10791079
file = strings.TrimSuffix(file, "_codspeed.go") + "_test.go"
1080+
file = removeFolderFromPath(file, "codspeed")
10801081
}
10811082
} else {
10821083
file = "???"

0 commit comments

Comments
 (0)