Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run test for traceback module #5649

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ports/unix/variants/coverage/mpconfigvariant.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SRC_BITMAP := \
shared-bindings/bitmaptools/__init__.c \
shared-bindings/displayio/Bitmap.c \
shared-bindings/rainbowio/__init__.c \
shared-bindings/traceback/__init__.c \
shared-bindings/util.c \
shared-module/aesio/aes.c \
shared-module/aesio/__init__.c \
Expand All @@ -45,11 +46,18 @@ SRC_BITMAP := \
shared-module/displayio/ColorConverter.c \
shared-module/displayio/ColorConverter.c \
shared-module/rainbowio/__init__.c \
shared-module/traceback/__init__.c

$(info $(SRC_BITMAP))
SRC_C += $(SRC_BITMAP)

CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_UNIX=1 -DCIRCUITPY_BITMAPTOOLS=1 -DCIRCUITPY_RAINBOWIO=1 -DCIRCUITPY_AESIO=1
CFLAGS += \
-DCIRCUITPY_AESIO=1 \
-DCIRCUITPY_BITMAPTOOLS=1 \
-DCIRCUITPY_DISPLAYIO_UNIX=1 \
-DCIRCUITPY_GIFIO=1 \
-DCIRCUITPY_RAINBOWIO=1 \
-DCIRCUITPY_TRACEBACK=1

SRC_C += coverage.c
SRC_CXX += coveragecpp.cpp
12 changes: 6 additions & 6 deletions shared-bindings/traceback/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj
STATIC mp_obj_t traceback_format_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_etype, ARG_value, ARG_tb, ARG_limit, ARG_chain };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_limit, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_chain, MP_ARG_BOOL, {.u_bool = true} },
};
Expand Down Expand Up @@ -127,9 +127,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_f
STATIC mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_etype, ARG_value, ARG_tb, ARG_limit, ARG_file, ARG_chain };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_etype, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_tb, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_limit, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_file, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_chain, MP_ARG_BOOL, {.u_bool = true} },
Expand Down
23 changes: 23 additions & 0 deletions tests/circuitpython/traceback_test.py.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

No Trace:
Exception: test

Default Trace:
Traceback (most recent call last):
File "circuitpython/traceback_test.py", line 13, in <module>
File "circuitpython/traceback_test.py", line 9, in fun
Exception: test

Limit=1 Trace:
Traceback (most recent call last):
File "circuitpython/traceback_test.py", line 13, in <module>
Exception: test

Limit=0 Trace:
Exception: test

Limit=-1 Trace:
Traceback (most recent call last):
File "circuitpython/traceback_test.py", line 9, in fun
Exception: test

3 changes: 3 additions & 0 deletions tests/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
skip_tests.add("basics/scope_implicit.py") # requires checking for unbound local
skip_tests.add("basics/try_finally_return2.py") # requires raise_varargs
skip_tests.add("basics/unboundlocal.py") # requires checking for unbound local
skip_tests.add(
"circuitpython/traceback_test.py"
) # because native doesn't have proper traceback info
skip_tests.add("extmod/uasyncio_event.py") # unknown issue
skip_tests.add("extmod/uasyncio_lock.py") # requires async with
skip_tests.add("extmod/uasyncio_micropython.py") # unknown issue
Expand Down
10 changes: 5 additions & 5 deletions tests/unix/extra_coverage.py.exp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ cexample cmath collections cppexample
displayio errno ffi framebuf
gc gifio hashlib json
math qrio rainbowio re
sys termios ubinascii uctypes
uerrno uheapq uio ujson
ulab uos urandom ure
uselect ustruct utime utimeq
uzlib
sys termios traceback ubinascii
uctypes uerrno uheapq uio
ujson ulab uos urandom
ure uselect ustruct utime
utimeq uzlib
ime

utime utimeq
Expand Down