#!/usr/bin/env python3 """Compare a native Chromium AT-SPI dump with a Wine Access publisher dump. Usage: compare_dumps.py NATIVE.txt PUBLISHER.txt [--baseline chromium|electron42] Exits 0 when the dumps match after the documented allowed differences, 1 otherwise, printing a unified diff of what remains. """ import argparse import difflib import re import sys # Differences that are real and expected, applied to the native side so it # reads as the Wine side would. Each rule documents its reason. ATTRIBUTE_LINE = re.compile(r'^(\s*attrs: )"(.*)" len=\d+$') ROLE_LINE = re.compile(r'^(\s*- )(\S.*?)( name=.*)$') # Lines that identify the run rather than the tree. ignoredPrefixes = ("application:",) def attribute_line(indent, attributes): joined = ";".join(attributes) return f'{indent}"{joined}" len={len(joined)}' def normalize(lines, baseline): result = list(lines) for index, line in enumerate(result): match = ATTRIBUTE_LINE.match(line) if not match: continue attributes = match.group(2).split(";") # Chromium's views frame class is platform-specific. attributes = ["class:WinFrameView" if item == "class:NativeFrameView" else item for item in attributes] # Electron 42's Chromium exposes an unnamed