Skip to content

Commit 33e6fed

Browse files
committed
fix: use the correct key format in reduction
1 parent 4de9b7c commit 33e6fed

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

internal/metamorphic/reduce_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ func (r *reducer) setupRunDirs(
150150
return testRootDir, runSubdirs
151151
}
152152

153+
func (r *reducer) getKeyFormat() metamorphic.KeyFormat {
154+
if len(r.configs) == 0 {
155+
return metamorphic.TestkeysKeyFormat
156+
}
157+
158+
optionsStr := string(r.configs[0].optionsData)
159+
if strings.Contains(optionsStr, "comparer=cockroach_comparator") {
160+
return metamorphic.CockroachKeyFormat
161+
}
162+
163+
// Default to TestkeysKeyFormat (pebble.internal.testkeys is the default)
164+
return metamorphic.TestkeysKeyFormat
165+
}
166+
153167
func (r *reducer) try(t *testing.T, ops []string) bool {
154168
testRootDir, runSubdirs := r.setupRunDirs(t, ops)
155169

@@ -195,7 +209,7 @@ func (r *reducer) try(t *testing.T, ops []string) bool {
195209

196210
// Try to generate a diagram.
197211
diagram, err := metamorphic.TryToGenerateDiagram(
198-
metamorphic.TestkeysKeyFormat,
212+
r.getKeyFormat(),
199213
[]byte(strings.Join(ops, "\n")),
200214
)
201215
require.NoError(t, err)
@@ -231,7 +245,7 @@ func (r *reducer) Run(t *testing.T) {
231245
// Try to simplify the keys.
232246
opsData := []byte(strings.Join(ops, "\n"))
233247
for _, retainSuffixes := range []bool{false, true} {
234-
newOpsData := metamorphic.TryToSimplifyKeys(metamorphic.TestkeysKeyFormat, opsData, retainSuffixes)
248+
newOpsData := metamorphic.TryToSimplifyKeys(r.getKeyFormat(), opsData, retainSuffixes)
235249
o := strings.Split(strings.TrimSpace(string(newOpsData)), "\n")
236250
if r.try(t, o) {
237251
return

0 commit comments

Comments
 (0)