Skip to content

Commit cdf6658

Browse files
committed
feat: add codspeed compat layer
1 parent ef47656 commit cdf6658

File tree

11 files changed

+151
-0
lines changed

11 files changed

+151
-0
lines changed

compat/testing/testing.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//go:build codspeed
2+
// +build codspeed
3+
4+
package codspeed
5+
6+
import (
7+
codspeed_testing "github.com/CodSpeedHQ/codspeed-go/testing/testing"
8+
)
9+
10+
type B = codspeed_testing.B
11+
type BenchmarkResult = codspeed_testing.BenchmarkResult
12+
type Cover = codspeed_testing.Cover
13+
type CoverBlock = codspeed_testing.CoverBlock
14+
type F = codspeed_testing.F
15+
type InternalBenchmark = codspeed_testing.InternalBenchmark
16+
type InternalExample = codspeed_testing.InternalExample
17+
type InternalFuzzTarget = codspeed_testing.InternalFuzzTarget
18+
type InternalTest = codspeed_testing.InternalTest
19+
type M = codspeed_testing.M
20+
type PB = codspeed_testing.PB
21+
type T = codspeed_testing.T
22+
type TB = codspeed_testing.TB
23+
24+
func AllocsPerRun(runs int, f func()) (avg float64) {
25+
return codspeed_testing.AllocsPerRun(runs, f)
26+
}
27+
28+
func CoverMode() string {
29+
return codspeed_testing.CoverMode()
30+
}
31+
32+
func Coverage() float64 {
33+
return codspeed_testing.Coverage()
34+
}
35+
36+
func Init() {
37+
codspeed_testing.Init()
38+
}
39+
40+
func Main(matchString func(pat, str string) (bool, error), tests []codspeed_testing.InternalTest, benchmarks []codspeed_testing.InternalBenchmark, examples []codspeed_testing.InternalExample) {
41+
codspeed_testing.Main(matchString, tests, benchmarks, examples)
42+
}
43+
44+
func RegisterCover(c codspeed_testing.Cover) {
45+
codspeed_testing.RegisterCover(c)
46+
}
47+
48+
func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []codspeed_testing.InternalBenchmark) {
49+
codspeed_testing.RunBenchmarks(matchString, benchmarks)
50+
}
51+
52+
func RunExamples(matchString func(pat, str string) (bool, error), examples []codspeed_testing.InternalExample) (ok bool) {
53+
return codspeed_testing.RunExamples(matchString, examples)
54+
}
55+
56+
func RunTests(matchString func(pat, str string) (bool, error), tests []codspeed_testing.InternalTest) (ok bool) {
57+
return codspeed_testing.RunTests(matchString, tests)
58+
}
59+
60+
func Short() bool {
61+
return codspeed_testing.Short()
62+
}
63+
64+
func Testing() bool {
65+
return codspeed_testing.Testing()
66+
}
67+
68+
func Verbose() bool {
69+
return codspeed_testing.Verbose()
70+
}

compat/testing/testing_compat.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//go:build !codspeed
2+
// +build !codspeed
3+
4+
package codspeed
5+
6+
import (
7+
stdtesting "testing"
8+
)
9+
10+
type B = stdtesting.B
11+
type BenchmarkResult = stdtesting.BenchmarkResult
12+
type Cover = stdtesting.Cover
13+
type CoverBlock = stdtesting.CoverBlock
14+
type F = stdtesting.F
15+
type InternalBenchmark = stdtesting.InternalBenchmark
16+
type InternalExample = stdtesting.InternalExample
17+
type InternalFuzzTarget = stdtesting.InternalFuzzTarget
18+
type InternalTest = stdtesting.InternalTest
19+
type M = stdtesting.M
20+
type PB = stdtesting.PB
21+
type T = stdtesting.T
22+
type TB = stdtesting.TB
23+
24+
func AllocsPerRun(runs int, f func()) (avg float64) {
25+
return stdtesting.AllocsPerRun(runs, f)
26+
}
27+
28+
func CoverMode() string {
29+
return stdtesting.CoverMode()
30+
}
31+
32+
func Coverage() float64 {
33+
return stdtesting.Coverage()
34+
}
35+
36+
func Init() {
37+
stdtesting.Init()
38+
}
39+
40+
func Main(matchString func(pat, str string) (bool, error), tests []stdtesting.InternalTest, benchmarks []stdtesting.InternalBenchmark, examples []stdtesting.InternalExample) {
41+
stdtesting.Main(matchString, tests, benchmarks, examples)
42+
}
43+
44+
func RegisterCover(c stdtesting.Cover) {
45+
stdtesting.RegisterCover(c)
46+
}
47+
48+
func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []stdtesting.InternalBenchmark) {
49+
stdtesting.RunBenchmarks(matchString, benchmarks)
50+
}
51+
52+
func RunExamples(matchString func(pat, str string) (bool, error), examples []stdtesting.InternalExample) (ok bool) {
53+
return stdtesting.RunExamples(matchString, examples)
54+
}
55+
56+
func RunTests(matchString func(pat, str string) (bool, error), tests []stdtesting.InternalTest) (ok bool) {
57+
return stdtesting.RunTests(matchString, tests)
58+
}
59+
60+
func Short() bool {
61+
return stdtesting.Short()
62+
}
63+
64+
func Testing() bool {
65+
return stdtesting.Testing()
66+
}
67+
68+
func Verbose() bool {
69+
return stdtesting.Verbose()
70+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 4ef9d6338b9285c7945a2d6bd04a2d28781fa175

go-runner/testdata/projects/fuego

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 15bb3a708ebfa1722b19bcb020408ac1bd4b7333

go-runner/testdata/projects/fzf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 04c4269db3f8058d2afc301dfba49d497249eb5c
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 96d27bb724d05ee920b4e4cf1be9493346673258

go-runner/testdata/projects/hugo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 3aa22b09425ab9e4e4d79c328ae16692cb3df736
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 69e81088ad40f45a0764597326722dea8f3f00a8

go-runner/testdata/projects/zap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 07077a697f639389cc998ff91b8885feb25f520d

go-runner/testdata/projects/zerolog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 9dacc014f38d60f563c2ab18719aec11fc06765c

0 commit comments

Comments
 (0)