summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-05-08 09:18:38 +0100
committerDamien George <damien.p.george@gmail.com>2015-05-08 09:18:38 +0100
commitd792d9e49ea89aa8a742f57d70e5b59c9d68939e (patch)
treeb82ccd67eb5b2651a7e6b7637a298da4e0617e71
parentd3b32caea410897d8bac849489b4558505869dfe (diff)
downloadmicropython-d792d9e49ea89aa8a742f57d70e5b59c9d68939e.tar.gz
micropython-d792d9e49ea89aa8a742f57d70e5b59c9d68939e.zip
unix: Make extra-coverage function callable from Python scripts.
This allows the output of the extra-coverage tests to be checked using the normal run-tests script.
-rw-r--r--.travis.yml2
-rw-r--r--tests/unix/extra_coverage.py8
-rw-r--r--tests/unix/extra_coverage.py.exp7
-rw-r--r--unix/coverage.c9
-rw-r--r--unix/main.c13
5 files changed, 27 insertions, 12 deletions
diff --git a/.travis.yml b/.travis.yml
index 5d9a383c16..c598783f44 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -35,8 +35,6 @@ script:
- make -C unix CC=gcc-4.7 coverage
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests)
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --emit native)
- # TODO the output of this extra coverage test is not checked
- - unix/micropython_coverage --coverage
after_success:
- (cd unix && coveralls --root .. --build-root . --gcov $(which gcov-4.7) --gcov-options '\-o build-coverage/' --include py --include extmod)
diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py
new file mode 100644
index 0000000000..8f330f1da2
--- /dev/null
+++ b/tests/unix/extra_coverage.py
@@ -0,0 +1,8 @@
+try:
+ extra_coverage
+except NameError:
+ print("SKIP")
+ import sys
+ sys.exit()
+
+extra_coverage()
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
new file mode 100644
index 0000000000..565b0dd040
--- /dev/null
+++ b/tests/unix/extra_coverage.py.exp
@@ -0,0 +1,7 @@
+ame__
+
+__name__ path argv version
+version_info implementation platform byteorder
+maxsize exit stdin stdout
+stderr exc_info print_exception
+ementation
diff --git a/unix/coverage.c b/unix/coverage.c
index 48dbfd5c7c..bc66ec3f11 100644
--- a/unix/coverage.c
+++ b/unix/coverage.c
@@ -7,13 +7,11 @@
#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) {
+STATIC mp_obj_t extra_coverage(void) {
// repl autocomplete
{
const char *str;
- mp_uint_t len = mp_repl_autocomplete("__", 2, &mp_plat_print, &str);
+ mp_uint_t len = mp_repl_autocomplete("__n", 3, &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)));
@@ -21,6 +19,9 @@ void run_extra_coverage_tests(void) {
len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str);
printf("%.*s\n", (int)len, str);
}
+
+ return mp_const_none;
}
+MP_DEFINE_CONST_FUN_OBJ_0(extra_coverage_obj, extra_coverage);
#endif
diff --git a/unix/main.c b/unix/main.c
index abea157286..9794f60836 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -356,6 +356,13 @@ int main(int argc, char **argv) {
mp_obj_list_init(mp_sys_argv, 0);
+ #if defined(MICROPY_UNIX_COVERAGE)
+ {
+ MP_DECLARE_CONST_FUN_OBJ(extra_coverage_obj);
+ mp_store_global(QSTR_FROM_STR_STATIC("extra_coverage"), (mp_obj_t)&extra_coverage_obj);
+ }
+ #endif
+
// Here is some example code to create a class and instance of that class.
// First is the Python, then the C code.
//
@@ -434,12 +441,6 @@ int main(int argc, char **argv) {
MP_STATE_VM(mp_optimise_value) = 0;
for (char *p = argv[a] + 1; *p && *p == 'O'; p++, MP_STATE_VM(mp_optimise_value)++);
}
- #if defined(MICROPY_UNIX_COVERAGE)
- } else if (strcmp(argv[a], "--coverage") == 0) {
- void run_extra_coverage_tests(void);
- run_extra_coverage_tests();
- ret = 0;
- #endif
} else {
return usage(argv);
}