Skip to content

Commit 5797b68

Browse files
authored
Merge pull request #5649 from microDev1/traceback
Run test for traceback module
2 parents 3908d4b + 69faaa5 commit 5797b68

File tree

5 files changed

+46
-12
lines changed

5 files changed

+46
-12
lines changed

ports/unix/variants/coverage/mpconfigvariant.mk

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ SRC_BITMAP := \
3636
shared-bindings/bitmaptools/__init__.c \
3737
shared-bindings/displayio/Bitmap.c \
3838
shared-bindings/rainbowio/__init__.c \
39+
shared-bindings/traceback/__init__.c \
3940
shared-bindings/util.c \
4041
shared-module/aesio/aes.c \
4142
shared-module/aesio/__init__.c \
@@ -45,11 +46,18 @@ SRC_BITMAP := \
4546
shared-module/displayio/ColorConverter.c \
4647
shared-module/displayio/ColorConverter.c \
4748
shared-module/rainbowio/__init__.c \
49+
shared-module/traceback/__init__.c
4850

4951
$(info $(SRC_BITMAP))
5052
SRC_C += $(SRC_BITMAP)
5153

52-
CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_UNIX=1 -DCIRCUITPY_BITMAPTOOLS=1 -DCIRCUITPY_RAINBOWIO=1 -DCIRCUITPY_AESIO=1
54+
CFLAGS += \
55+
-DCIRCUITPY_AESIO=1 \
56+
-DCIRCUITPY_BITMAPTOOLS=1 \
57+
-DCIRCUITPY_DISPLAYIO_UNIX=1 \
58+
-DCIRCUITPY_GIFIO=1 \
59+
-DCIRCUITPY_RAINBOWIO=1 \
60+
-DCIRCUITPY_TRACEBACK=1
5361

5462
SRC_C += coverage.c
5563
SRC_CXX += coveragecpp.cpp

shared-bindings/traceback/__init__.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj
8585
STATIC mp_obj_t traceback_format_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
8686
enum { ARG_etype, ARG_value, ARG_tb, ARG_limit, ARG_chain };
8787
static const mp_arg_t allowed_args[] = {
88-
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED },
89-
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED },
90-
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED },
88+
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
89+
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
90+
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
9191
{ MP_QSTR_limit, MP_ARG_OBJ, {.u_obj = mp_const_none} },
9292
{ MP_QSTR_chain, MP_ARG_BOOL, {.u_bool = true} },
9393
};
@@ -127,9 +127,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_f
127127
STATIC mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
128128
enum { ARG_etype, ARG_value, ARG_tb, ARG_limit, ARG_file, ARG_chain };
129129
static const mp_arg_t allowed_args[] = {
130-
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED },
131-
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED },
132-
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED },
130+
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
131+
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
132+
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
133133
{ MP_QSTR_limit, MP_ARG_OBJ, {.u_obj = mp_const_none} },
134134
{ MP_QSTR_file, MP_ARG_OBJ, {.u_obj = mp_const_none} },
135135
{ MP_QSTR_chain, MP_ARG_BOOL, {.u_bool = true} },
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
No Trace:
3+
Exception: test
4+
5+
Default Trace:
6+
Traceback (most recent call last):
7+
File "circuitpython/traceback_test.py", line 13, in <module>
8+
File "circuitpython/traceback_test.py", line 9, in fun
9+
Exception: test
10+
11+
Limit=1 Trace:
12+
Traceback (most recent call last):
13+
File "circuitpython/traceback_test.py", line 13, in <module>
14+
Exception: test
15+
16+
Limit=0 Trace:
17+
Exception: test
18+
19+
Limit=-1 Trace:
20+
Traceback (most recent call last):
21+
File "circuitpython/traceback_test.py", line 9, in fun
22+
Exception: test
23+

tests/run-tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
511511
skip_tests.add("basics/scope_implicit.py") # requires checking for unbound local
512512
skip_tests.add("basics/try_finally_return2.py") # requires raise_varargs
513513
skip_tests.add("basics/unboundlocal.py") # requires checking for unbound local
514+
skip_tests.add(
515+
"circuitpython/traceback_test.py"
516+
) # because native doesn't have proper traceback info
514517
skip_tests.add("extmod/uasyncio_event.py") # unknown issue
515518
skip_tests.add("extmod/uasyncio_lock.py") # requires async with
516519
skip_tests.add("extmod/uasyncio_micropython.py") # unknown issue

tests/unix/extra_coverage.py.exp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ cexample cmath collections cppexample
3535
displayio errno ffi framebuf
3636
gc gifio hashlib json
3737
math qrio rainbowio re
38-
sys termios ubinascii uctypes
39-
uerrno uheapq uio ujson
40-
ulab uos urandom ure
41-
uselect ustruct utime utimeq
42-
uzlib
38+
sys termios traceback ubinascii
39+
uctypes uerrno uheapq uio
40+
ujson ulab uos urandom
41+
ure uselect ustruct utime
42+
utimeq uzlib
4343
ime
4444

4545
utime utimeq

0 commit comments

Comments
 (0)