@@ -29,6 +29,7 @@ import (
29
29
"os"
30
30
"path"
31
31
"regexp"
32
+ "slices"
32
33
"strings"
33
34
"sync"
34
35
"testing"
@@ -1115,6 +1116,32 @@ func featureGatesMerge(src map[featuregate.Feature]bool, overrides map[featurega
1115
1116
return result
1116
1117
}
1117
1118
1119
+ // fixJSONOutput works around Go not emitting a "pass" action for
1120
+ // sub-benchmarks
1121
+ // (https://github.com/golang/go/issues/66825#issuecomment-2343229005), which
1122
+ // causes gotestsum to report a successful benchmark run as failed
1123
+ // (https://github.com/gotestyourself/gotestsum/issues/413#issuecomment-2343206787).
1124
+ //
1125
+ // It does this by printing the missing "PASS" output line that test2json
1126
+ // then converts into the "pass" action.
1127
+ func fixJSONOutput (b * testing.B ) {
1128
+ if ! slices .Contains (os .Args , "-test.v=test2json" ) {
1129
+ // Not printing JSON.
1130
+ return
1131
+ }
1132
+
1133
+ start := time .Now ()
1134
+ b .Cleanup (func () {
1135
+ if b .Failed () {
1136
+ // Really has failed, do nothing.
1137
+ return
1138
+ }
1139
+ // SYN gets injected when using -test.v=test2json, see
1140
+ // https://cs.opensource.google/go/go/+/refs/tags/go1.23.3:src/testing/testing.go;drc=87ec2c959c73e62bfae230ef7efca11ec2a90804;l=527
1141
+ fmt .Fprintf (os .Stderr , "%c--- PASS: %s (%.2fs)\n " , 22 /* SYN */ , b .Name (), time .Since (start ).Seconds ())
1142
+ })
1143
+ }
1144
+
1118
1145
// RunBenchmarkPerfScheduling runs the scheduler performance benchmark tests.
1119
1146
//
1120
1147
// You can pass your own scheduler plugins via outOfTreePluginRegistry.
@@ -1128,6 +1155,7 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
1128
1155
if err = validateTestCases (testCases ); err != nil {
1129
1156
b .Fatal (err )
1130
1157
}
1158
+ fixJSONOutput (b )
1131
1159
1132
1160
if testing .Short () {
1133
1161
PerfSchedulingLabelFilter += ",+short"
@@ -1147,11 +1175,13 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
1147
1175
dataItems := DataItems {Version : "v1" }
1148
1176
for _ , tc := range testCases {
1149
1177
b .Run (tc .Name , func (b * testing.B ) {
1178
+ fixJSONOutput (b )
1150
1179
for _ , w := range tc .Workloads {
1151
1180
b .Run (w .Name , func (b * testing.B ) {
1152
1181
if ! enabled (testcaseLabelSelectors , append (tc .Labels , w .Labels ... )... ) {
1153
1182
b .Skipf ("disabled by label filter %q" , PerfSchedulingLabelFilter )
1154
1183
}
1184
+ fixJSONOutput (b )
1155
1185
1156
1186
featureGates := featureGatesMerge (tc .FeatureGates , w .FeatureGates )
1157
1187
informerFactory , tCtx := setupTestCase (b , tc , featureGates , output , outOfTreePluginRegistry )
0 commit comments