summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-09-19 12:05:39 +1000
committerDamien George <damien@micropython.org>2022-09-19 23:51:10 +1000
commit920da9c5e30da58d5f77b2c5e28c74e3670e6a3b (patch)
tree6a60c130a453e957d737a652c8d0c974b2fe69c9
parent6ecdf1a240e43bd60c824c7efd575c0a82d02d7e (diff)
downloadmicropython-920da9c5e30da58d5f77b2c5e28c74e3670e6a3b.tar.gz
micropython-920da9c5e30da58d5f77b2c5e28c74e3670e6a3b.zip
unix/variants/coverage: Add test for manifest freeze_mpy().
This uses the frozentest.mpy that is also used by ports/minimal. Also fixes two bugs that these new tests picked up: - File extension matching in manifestfile.py. - Handling of freeze_mpy results in makemanifest. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
-rw-r--r--ports/unix/variants/coverage/manifest.py1
-rw-r--r--tests/unix/extra_coverage.py5
-rw-r--r--tests/unix/extra_coverage.py.exp10
-rw-r--r--tools/makemanifest.py6
-rw-r--r--tools/manifestfile.py17
5 files changed, 32 insertions, 7 deletions
diff --git a/ports/unix/variants/coverage/manifest.py b/ports/unix/variants/coverage/manifest.py
index 6111050884..7c3d9a6b64 100644
--- a/ports/unix/variants/coverage/manifest.py
+++ b/ports/unix/variants/coverage/manifest.py
@@ -1,2 +1,3 @@
freeze_as_str("frzstr")
freeze_as_mpy("frzmpy")
+freeze_mpy("$(MPY_DIR)/tests/frozen")
diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py
index bb22485026..00226a68e6 100644
--- a/tests/unix/extra_coverage.py
+++ b/tests/unix/extra_coverage.py
@@ -96,3 +96,8 @@ import frzmpy3
from frzqstr import returns_NULL
print(returns_NULL())
+
+# test for freeze_mpy
+import frozentest
+
+print(frozentest.__file__)
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 4d6e1e0856..2941154556 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -199,3 +199,13 @@ X
'\x1b'
b'\x00\xff'
NULL
+uPy
+a long string that is not interned
+a string that has unicode αβγ chars
+b'bytes 1234\x01'
+123456789
+0
+1
+2
+3
+frozentest.py
diff --git a/tools/makemanifest.py b/tools/makemanifest.py
index 9dd8815aac..b2e4f7d844 100644
--- a/tools/makemanifest.py
+++ b/tools/makemanifest.py
@@ -210,9 +210,9 @@ def main():
ts_outfile = get_timestamp(outfile)
mpy_files.append(outfile)
else:
- assert kind == manifestfile.KIND_FREEZE_MPY
- mpy_files.append(full_path)
- ts_outfile = timestamp
+ assert result.kind == manifestfile.KIND_FREEZE_MPY
+ mpy_files.append(result.full_path)
+ ts_outfile = result.timestamp
ts_newest = max(ts_newest, ts_outfile)
# Check if output file needs generating
diff --git a/tools/manifestfile.py b/tools/manifestfile.py
index 84c79ed82b..a4d056137f 100644
--- a/tools/manifestfile.py
+++ b/tools/manifestfile.py
@@ -394,28 +394,37 @@ class ManifestFile:
`opt` is the optimisation level to pass to mpy-cross when compiling .py
to .mpy.
"""
- self._freeze_internal(path, script, exts=(".py", ".mpy"), kind=KIND_FREEZE_AUTO, opt=opt)
+ self._freeze_internal(
+ path,
+ script,
+ exts=(
+ ".py",
+ ".mpy",
+ ),
+ kind=KIND_FREEZE_AUTO,
+ opt=opt,
+ )
def freeze_as_str(self, path):
"""
Freeze the given `path` and all .py scripts within it as a string,
which will be compiled upon import.
"""
- self._search(path, None, None, exts=(".py"), kind=KIND_FREEZE_AS_STR)
+ self._search(path, None, None, exts=(".py",), kind=KIND_FREEZE_AS_STR)
def freeze_as_mpy(self, path, script=None, opt=None):
"""
Freeze the input (see above) by first compiling the .py scripts to
.mpy files, then freezing the resulting .mpy files.
"""
- self._freeze_internal(path, script, exts=(".py"), kind=KIND_FREEZE_AS_MPY, opt=opt)
+ self._freeze_internal(path, script, exts=(".py",), kind=KIND_FREEZE_AS_MPY, opt=opt)
def freeze_mpy(self, path, script=None, opt=None):
"""
Freeze the input (see above), which must be .mpy files that are
frozen directly.
"""
- self._freeze_internal(path, script, exts=(".mpy"), kind=KIND_FREEZE_MPY, opt=opt)
+ self._freeze_internal(path, script, exts=(".mpy",), kind=KIND_FREEZE_MPY, opt=opt)
# Generate a temporary file with a line appended to the end that adds __version__.