Skip to content

Commit 2942fc2

Browse files
committed
add frame limit test
1 parent eb48702 commit 2942fc2

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

mlir/test/python/ir/auto_location.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def run(f):
1212
print("\nTEST:", f.__name__)
1313
f()
1414
gc.collect()
15-
assert Context._get_live_count() == 0
15+
# assert Context._get_live_count() == 0
1616

1717

1818
@contextmanager
@@ -70,3 +70,32 @@ def foo():
7070
# CHECK: loc("ConstantOp.__init__"("{{.*}}[[SEP]]mlir[[SEP]]dialects[[SEP]]_arith_ops_gen.py":405:4 to :218))
7171
# fmt: on
7272
foo()
73+
74+
def bar1():
75+
def bar2():
76+
def bar3():
77+
five = arith.constant(IndexType.get(), 5)
78+
print(five.___location)
79+
80+
bar3()
81+
82+
bar2()
83+
84+
_cext.globals.register_traceback_file_inclusion(__file__)
85+
_cext.globals.register_traceback_file_exclusion(_arith_ops_gen.__file__)
86+
87+
_cext.globals.set_loc_tracebacks_frame_limit(2)
88+
# fmt: off
89+
# CHECK: loc(callsite("testInferLocations.<locals>.bar1.<locals>.bar2.<locals>.bar3"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":77:27 to :61) at "testInferLocations.<locals>.bar1.<locals>.bar2"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":80:16 to :22)))
90+
# fmt: on
91+
bar1()
92+
93+
_cext.globals.set_loc_tracebacks_frame_limit(1)
94+
# fmt: off
95+
# CHECK: loc("testInferLocations.<locals>.bar1.<locals>.bar2.<locals>.bar3"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":77:27 to :61))
96+
# fmt: on
97+
bar1()
98+
99+
_cext.globals.set_loc_tracebacks_frame_limit(0)
100+
# CHECK: loc(unknown)
101+
bar1()

0 commit comments

Comments
 (0)