Skip to content

Commit 7dd3cfa

Browse files
committed
add benchspy unit tests
1 parent 072556d commit 7dd3cfa

File tree

9 files changed

+1932
-32
lines changed

9 files changed

+1932
-32
lines changed

wasp/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ test:
66
test_race:
77
go test -v -race -count 1 `go list ./... | grep -v examples` -run TestSmoke
88

9+
.PHONY: test_benchspy_race
10+
test_benchspy_race:
11+
go test -v -race -count 1 `go list ./... | grep -v examples | grep benchspy` -run TestBenchSpy
12+
913
.PHONY: test_bench
1014
test_bench:
1115
go test -bench=. -benchmem -count 1 -run=^#

wasp/benchspy/basic.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ func (b *BasicData) FillStartEndTimes() error {
5858
var latestTime time.Time
5959

6060
for _, cfg := range b.GeneratorConfigs {
61+
if len(cfg.Schedule) == 0 {
62+
return fmt.Errorf("schedule is empty for generator %s", cfg.GenName)
63+
}
64+
6165
for _, segment := range cfg.Schedule {
6266
if segment.StartTime.IsZero() {
6367
return fmt.Errorf("start time is missing in one of the segments belonging to generator %s. Did that generator run?", cfg.GenName)
@@ -111,16 +115,13 @@ func (b *BasicData) IsComparable(otherData BasicData) error {
111115
}
112116
}
113117

114-
for name2 := range otherData.GeneratorConfigs {
115-
if _, ok := b.GeneratorConfigs[name2]; !ok {
116-
return fmt.Errorf("generator config %s is missing from the current report", name2)
117-
}
118-
}
119-
120118
return nil
121119
}
122120

123121
func compareGeneratorConfigs(cfg1, cfg2 *wasp.Config) error {
122+
if cfg1.GenName != cfg2.GenName {
123+
return fmt.Errorf("generator names are different. Expected %s, got %s", cfg1.GenName, cfg2.GenName)
124+
}
124125
if cfg1.LoadType != cfg2.LoadType {
125126
return fmt.Errorf("load types are different. Expected %s, got %s", cfg1.LoadType, cfg2.LoadType)
126127
}
@@ -136,13 +137,13 @@ func compareGeneratorConfigs(cfg1, cfg2 *wasp.Config) error {
136137
for i, segment1 := range cfg1.Schedule {
137138
segment2 := cfg2.Schedule[i]
138139
if segment1 == nil {
139-
return fmt.Errorf("schedule at index %d is nil in the current report", i)
140+
return fmt.Errorf("segment at index %d is nil in the current report", i)
140141
}
141142
if segment2 == nil {
142-
return fmt.Errorf("schedule at index %d is nil in the other report", i)
143+
return fmt.Errorf("segment at index %d is nil in the other report", i)
143144
}
144145
if !areSegmentsEqual(segment1, segment2) {
145-
return fmt.Errorf("schedules at index %d are different. Expected %s, got %s", i, mustMarshallSegment(segment1), mustMarshallSegment(segment2))
146+
return fmt.Errorf("segments at index %d are different. Expected %s segment(s), got %s segment(s)", i, mustMarshallSegment(segment1), mustMarshallSegment(segment2))
146147
}
147148
}
148149

0 commit comments

Comments
 (0)