Skip to content

Commit 1f43d49

Browse files
committed
tests/micropython: Move alloc-less traceback test to separate test file.
The native emitter doesn't provide proper traceback info so this test should not be run in that case.
1 parent d70f87a commit 1f43d49

5 files changed

Lines changed: 28 additions & 18 deletions

File tree

tests/micropython/heapalloc.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# check that we can do certain things without allocating heap memory
22

33
import micropython
4-
import sys
54

65
def f1(a):
76
print(a)
@@ -18,13 +17,6 @@ def f3(a, b, c, d):
1817

1918
global_var = 1
2019

21-
# preallocate exception instance with some room for a traceback
22-
global_exc = StopIteration()
23-
try:
24-
raise global_exc
25-
except:
26-
pass
27-
2820
def test():
2921
global global_var, global_exc
3022
global_var = 2 # set an existing global variable
@@ -36,13 +28,6 @@ def test():
3628
f2(i, i) # 2 args
3729
f3(1, 2, 3, 4) # function with lots of local state
3830

39-
# test that we can generate a traceback without allocating
40-
global_exc.__traceback__ = None
41-
try:
42-
raise global_exc
43-
except StopIteration as e:
44-
sys.print_exception(e)
45-
4631
# call test() with heap allocation disabled
4732
micropython.heap_lock()
4833
test()

tests/micropython/heapalloc.py.exp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@
99
1 2
1010
1 1
1111
1 2 3 4 10
12-
Traceback (most recent call last):
13-
File "micropython/heapalloc.py", line 42, in test
14-
StopIteration:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# test that we can generate a traceback without allocating
2+
3+
import micropython
4+
import sys
5+
6+
# preallocate exception instance with some room for a traceback
7+
global_exc = StopIteration()
8+
try:
9+
raise global_exc
10+
except:
11+
pass
12+
13+
def test():
14+
global global_exc
15+
global_exc.__traceback__ = None
16+
try:
17+
raise global_exc
18+
except StopIteration as e:
19+
sys.print_exception(e)
20+
21+
# call test() with heap allocation disabled
22+
micropython.heap_lock()
23+
test()
24+
micropython.heap_unlock()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Traceback (most recent call last):
2+
File "micropython/heapalloc_traceback.py", line 17, in test
3+
StopIteration:

tests/run-tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def run_tests(pyb, tests, args):
291291
skip_tests.add('misc/rge_sm.py') # requires yield
292292
skip_tests.add('misc/print_exception.py') # because native doesn't have proper traceback info
293293
skip_tests.add('misc/sys_exc_info.py') # sys.exc_info() is not supported for native
294+
skip_tests.add('micropython/heapalloc_traceback.py') # because native doesn't have proper traceback info
294295

295296
for test_file in tests:
296297
test_file = test_file.replace('\\', '/')

0 commit comments

Comments
 (0)