summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xtools/ci.sh10
-rwxr-xr-xtools/mpy-tool.py8
2 files changed, 14 insertions, 4 deletions
diff --git a/tools/ci.sh b/tools/ci.sh
index 5b108d6202..682c3ae507 100755
--- a/tools/ci.sh
+++ b/tools/ci.sh
@@ -118,9 +118,19 @@ function ci_mpy_format_test {
python2.7 ./tools/mpy-tool.py -xd tests/frozen/frozentest.mpy
python3 ./tools/mpy-tool.py -xd tests/frozen/frozentest.mpy
+ # Build MicroPython
+ ci_unix_standard_build
+ micropython=./ports/unix/build-standard/micropython
+ $micropython -m mip install --target . argparse __future__
+ export MICROPYPATH=.
+
+ # Test mpy-tool.py running under MicroPython
+ $micropython ./tools/mpy-tool.py -x -d tests/frozen/frozentest.mpy
+
# Test mpy-tool.py dump feature on native code
make -C examples/natmod/features1
./tools/mpy-tool.py -xd examples/natmod/features1/features1.mpy
+ $micropython ./tools/mpy-tool.py -x -d examples/natmod/features1/features1.mpy
}
########################################################################################
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py
index cdceae3746..0094c12177 100755
--- a/tools/mpy-tool.py
+++ b/tools/mpy-tool.py
@@ -24,11 +24,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-# Python 2/3 compatibility code
+# Python 2/3/MicroPython compatibility code
from __future__ import print_function
-import platform
+import sys
-if platform.python_version_tuple()[0] == "2":
+if sys.version_info[0] == 2:
from binascii import hexlify as hexlify_py2
str_cons = lambda val, enc=None: str(val)
@@ -41,7 +41,7 @@ if platform.python_version_tuple()[0] == "2":
x = hexlify_py2(b)
return ":".join(x[i : i + 2] for i in range(0, len(x), 2))
-else:
+elif sys.version_info[0] == 3: # Also handles MicroPython
from binascii import hexlify
str_cons = str