From 69faaa52b824fa38b9367d3d37729f8125775fcf Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 2 Dec 2021 11:11:11 +0530 Subject: [PATCH] run test for traceback module --- .../unix/variants/coverage/mpconfigvariant.mk | 10 +++++++- shared-bindings/traceback/__init__.c | 12 +++++----- tests/circuitpython/traceback_test.py.exp | 23 +++++++++++++++++++ tests/run-tests.py | 3 +++ tests/unix/extra_coverage.py.exp | 10 ++++---- 5 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 tests/circuitpython/traceback_test.py.exp diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index d924fc7146..7e8aabef5b 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -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 \ @@ -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 diff --git a/shared-bindings/traceback/__init__.c b/shared-bindings/traceback/__init__.c index 7079148ba0..6fdb060439 100644 --- a/shared-bindings/traceback/__init__.c +++ b/shared-bindings/traceback/__init__.c @@ -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} }, }; @@ -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} }, diff --git a/tests/circuitpython/traceback_test.py.exp b/tests/circuitpython/traceback_test.py.exp new file mode 100644 index 0000000000..be887f2421 --- /dev/null +++ b/tests/circuitpython/traceback_test.py.exp @@ -0,0 +1,23 @@ + +No Trace: +Exception: test + +Default Trace: +Traceback (most recent call last): + File "circuitpython/traceback_test.py", line 13, in + 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 +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 + diff --git a/tests/run-tests.py b/tests/run-tests.py index b795d6ec94..34372590a2 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -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 diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 54efc744cb..4cce80a412 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -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