Skip to content

Commit 058c925

Browse files
committed
Ensure that we are comparing a useful set of Python builds
1 parent d758215 commit 058c925

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

Tools/coinstall-check/compare.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313

1414
def compare_trees(base: Path) -> bool:
15-
seen: dict[str, str] = {}
15+
"""Compare all json manifests inside the directory at base."""
16+
hashes_seen: dict[str, str] = {}
17+
tags_seen_by_platform: dict[str, set[frozenset[str]]] = {}
18+
1619
success: bool = True
1720
for tree in base.iterdir():
1821
if not tree.is_file():
@@ -24,17 +27,33 @@ def compare_trees(base: Path) -> bool:
2427
data = json.load(f)
2528
build_details = data["build_details"]
2629
hashes = data["hashes"]
30+
tags_seen_by_platform.setdefault(build_details["platform"], set()).add(frozenset(build_details["abi"]["flags"]))
2731

2832
for path, digest in hashes.items():
2933
if is_ignored(path, build_details):
3034
continue
31-
if path not in seen:
32-
seen[path] = digest
35+
if path not in hashes_seen:
36+
hashes_seen[path] = digest
3337
continue
34-
if digest != seen[path]:
38+
if digest != hashes_seen[path]:
3539
print(f"Mismatch found in {tree}: {path}")
36-
print(f"{digest} != {seen[path]}")
40+
print(f"{digest} != {hashes_seen[path]}")
3741
success = False
42+
43+
# Did we see enough builds to make a useful comparison?
44+
if len(tags_seen_by_platform) < 2:
45+
print(
46+
"Insufficient platforms (architectures) to compare. Expected >= 2"
47+
)
48+
success = False
49+
50+
for platform, tagsets in tags_seen_by_platform.items():
51+
if len(tagsets) >= 2:
52+
break
53+
else:
54+
print("Insufficient configuration variants tested. Expected >= 2")
55+
success = False
56+
3857
return success
3958

4059

0 commit comments

Comments
 (0)