@@ -23,26 +23,26 @@ def pytest_configure(config) -> None:
2323def assert_or_update_show_output (
2424 actual_text : str , expected_file : Path , * , update : bool , path_replacements : dict [str , str ] | None = None
2525) -> None :
26- def _normalize_panic_symbol_hashes (text : str ) -> str :
27- # Full panic symbol in mangled form .
28- text = re .sub (r'_ZN4core9panicking5panic17h [0-9a-f]+E' , '_ZN4core9panicking5panic17h <hash>E' , text )
29- # Truncated panic symbol shown by `kmir show --statistics --leaves `.
30- text = re .sub (r'_ZN4core9panicking5panic17h [0-9a-f]+' , '_ZN4core9panicking5panic17h <hash>' , text )
31- # Demangled panic symbol .
32- text = re .sub (r'core::panicking::panic::h [0-9a-f]+ ' , 'core::panicking::panic::h <hash>' , text )
26+ def _normalize_symbol_hashes (text : str ) -> str :
27+ # Mangled symbol hash suffixes can drift across rustc versions/builds .
28+ text = re .sub (r'(_ZN [0-9A-Za-z_]+17h)[0- 9a-f]+E' , r'\1 <hash>E' , text )
29+ # Some show outputs truncate mangled symbols before trailing `E `.
30+ text = re .sub (r'(_ZN [0-9A-Za-z_]+17h)[0- 9a-f]+' , r'\1 <hash>' , text )
31+ # Normalize demangled hash suffixes (`...::h<hex>`) .
32+ text = re .sub (r'(::h) [0-9a-f]{8,} ' , r'\1 <hash>' , text )
3333 return text
3434
3535 if path_replacements :
3636 for old , new in path_replacements .items ():
3737 actual_text = actual_text .replace (old , new )
38- # Normalize rustc panic symbol hash suffixes that can drift across builds/environments.
39- actual_text = _normalize_panic_symbol_hashes (actual_text )
38+ # Normalize rustc symbol hash suffixes that can drift across builds/environments.
39+ actual_text = _normalize_symbol_hashes (actual_text )
4040 if update :
4141 expected_file .write_text (actual_text )
4242 else :
4343 assert expected_file .is_file ()
4444 expected_text = expected_file .read_text ()
45- expected_text = _normalize_panic_symbol_hashes (expected_text )
45+ expected_text = _normalize_symbol_hashes (expected_text )
4646 if actual_text != expected_text :
4747 diff = '\n ' .join (
4848 unified_diff (
0 commit comments