Skip to content

Commit 7966a30

Browse files
committed
Normalize panic symbol hashes in show fixture assertions
1 parent d4bf1ba commit 7966a30

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

kmir/src/kmir/testing/fixtures.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import re
4+
import sys
35
from difflib import unified_diff
46
from typing import TYPE_CHECKING
57

@@ -13,8 +15,6 @@
1315

1416
from pytest import FixtureRequest, Parser
1517

16-
import sys
17-
1818

1919
def pytest_configure(config) -> None:
2020
sys.setrecursionlimit(1000000)
@@ -26,11 +26,18 @@ def assert_or_update_show_output(
2626
if path_replacements:
2727
for old, new in path_replacements.items():
2828
actual_text = actual_text.replace(old, new)
29+
# Normalize rustc panic symbol hash suffixes that can drift across builds/environments.
30+
actual_text = re.sub(r'_ZN4core9panicking5panic17h[0-9a-f]+E', '_ZN4core9panicking5panic17h<hash>E', actual_text)
31+
actual_text = re.sub(r'core::panicking::panic::h[0-9a-f]+', 'core::panicking::panic::h<hash>', actual_text)
2932
if update:
3033
expected_file.write_text(actual_text)
3134
else:
3235
assert expected_file.is_file()
3336
expected_text = expected_file.read_text()
37+
expected_text = re.sub(
38+
r'_ZN4core9panicking5panic17h[0-9a-f]+E', '_ZN4core9panicking5panic17h<hash>E', expected_text
39+
)
40+
expected_text = re.sub(r'core::panicking::panic::h[0-9a-f]+', 'core::panicking::panic::h<hash>', expected_text)
3441
if actual_text != expected_text:
3542
diff = '\n'.join(
3643
unified_diff(

kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.cli-stats-leaves.expected

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
│ (566 steps)
77
└─ 3 (stuck, leaf)
8-
#setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) ,
8+
#setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h3
99
span: no-location:0
1010

1111

@@ -32,7 +32,4 @@ Leaf paths from init:
3232
LEAF <k> CELLS
3333
---------------
3434
Node 3:
35-
#setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , id: defId ( 38 ) , body: noBody ) , operandConstant ( constOperand ( ... span: span ( 32 ) , userTy: noUserTypeAnnotationIndex , const: mirConst ( ... kind: constantKindAllocated ( allocation ( ... bytes: b"\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap ( ... ptrs: provenanceMapEntry ( ... offset: 0 , allocId: allocId ( 1 ) ) .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 39 ) , id: mirConstId ( 25 ) ) ) ) .Operands , span ( 117 ) ) ~> .K
36-
>> function: core::panicking::panic::h941160ead03e2d54
37-
>> call span: <REPO>/kmir/src/tests/integration/data/prove-rs/symbolic-args-fail.rs:53:5
38-
>> message: 'assertion failed: false'
35+
#setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h<hash>E" ) , id: defId ( 38 ) , body: noBody ) , operandConstant ( constOperand ( ... span: span ( 32 ) , userTy: noUserTypeAnnotationIndex , const: mirConst ( ... kind: constantKindAllocated ( allocation ( ... bytes: b"\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap ( ... ptrs: provenanceMapEntry ( ... offset: 0 , allocId: allocId ( 1 ) ) .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 39 ) , id: mirConstId ( 25 ) ) ) ) .Operands , span ( 117 ) ) ~> .K

0 commit comments

Comments
 (0)