test(playlists): the same-day determinism test names the mix that changed
release / go (push) Successful in 1m47s
release / web (push) Successful in 1m8s
release / govulncheck (push) Successful in 27s
release / integration (push) Failing after 4m2s
release / android (push) Successful in 4m48s
release / Build signed APK (push) Successful in 5m7s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
release / go (push) Successful in 1m47s
release / web (push) Successful in 1m8s
release / govulncheck (push) Successful in 27s
release / integration (push) Failing after 4m2s
release / android (push) Successful in 4m48s
release / Build signed APK (push) Successful in 5m7s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -439,7 +441,7 @@ func TestBuildSystemPlaylists_DailyNonceDeterminism(t *testing.T) {
|
||||
snap2 := snapshotSystemTracks(t, pool, u.ID)
|
||||
|
||||
if !equalSnapshots(snap1, snap2) {
|
||||
t.Errorf("same-day rebuild produced different track lists")
|
||||
t.Errorf("same-day rebuild produced different track lists: %s", describeSnapshotDiff(snap1, snap2))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,6 +472,46 @@ func snapshotSystemTracks(t *testing.T, pool *pgxpool.Pool, userID pgtype.UUID)
|
||||
return out
|
||||
}
|
||||
|
||||
// describeSnapshotDiff names each playlist that differs between two
|
||||
// snapshots: missing from one side, a different length, or the first
|
||||
// position whose track differs. Says which mix broke determinism, not
|
||||
// only that one did.
|
||||
func describeSnapshotDiff(a, b map[string][]string) string {
|
||||
names := map[string]bool{}
|
||||
for k := range a {
|
||||
names[k] = true
|
||||
}
|
||||
for k := range b {
|
||||
names[k] = true
|
||||
}
|
||||
sorted := make([]string, 0, len(names))
|
||||
for k := range names {
|
||||
sorted = append(sorted, k)
|
||||
}
|
||||
sort.Strings(sorted)
|
||||
var parts []string
|
||||
for _, k := range sorted {
|
||||
va, okA := a[k]
|
||||
vb, okB := b[k]
|
||||
switch {
|
||||
case !okA:
|
||||
parts = append(parts, fmt.Sprintf("%q only in the second build (%d tracks)", k, len(vb)))
|
||||
case !okB:
|
||||
parts = append(parts, fmt.Sprintf("%q only in the first build (%d tracks)", k, len(va)))
|
||||
case len(va) != len(vb):
|
||||
parts = append(parts, fmt.Sprintf("%q has %d tracks then %d", k, len(va), len(vb)))
|
||||
default:
|
||||
for i := range va {
|
||||
if va[i] != vb[i] {
|
||||
parts = append(parts, fmt.Sprintf("%q first differs at position %d of %d", k, i, len(va)))
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, "; ")
|
||||
}
|
||||
|
||||
func equalSnapshots(a, b map[string][]string) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user