diff options
author | Damien George <damien.p.george@gmail.com> | 2015-05-08 00:19:56 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-08 00:19:56 +0100 |
commit | d3b32caea410897d8bac849489b4558505869dfe (patch) | |
tree | dd914fed2f39943b8d05f377cd6ff70a160e3518 /unix/coverage.c | |
parent | 0589c19d5239bb4456f06049925d71851e896d1e (diff) | |
download | micropython-d3b32caea410897d8bac849489b4558505869dfe.tar.gz micropython-d3b32caea410897d8bac849489b4558505869dfe.zip |
unix: Add special function to improve coverage.
The function and corresponding command-line option are only enabled for
the coverage build. They are used to exercise uPy features that can't
be properly tested by Python scripts.
Diffstat (limited to 'unix/coverage.c')
-rw-r--r-- | unix/coverage.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/unix/coverage.c b/unix/coverage.c new file mode 100644 index 0000000000..48dbfd5c7c --- /dev/null +++ b/unix/coverage.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +#include "py/obj.h" +#include "py/runtime.h" +#include "py/repl.h" + +#if defined(MICROPY_UNIX_COVERAGE) + +// function to run extra tests for things that can't be checked by scripts +void run_extra_coverage_tests(void); + +void run_extra_coverage_tests(void) { + // repl autocomplete + { + const char *str; + mp_uint_t len = mp_repl_autocomplete("__", 2, &mp_plat_print, &str); + printf("%.*s\n", (int)len, str); + + mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0))); + mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str); + len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str); + printf("%.*s\n", (int)len, str); + } +} + +#endif |