Skip to content

Commit

Permalink
Upgrade micropython tests to use v1.22, initial circuitpython work
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Dec 27, 2023
1 parent 84842e3 commit f85a38c
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 86 deletions.
Binary file modified bin/micropython
Binary file not shown.
79 changes: 0 additions & 79 deletions libs/micropython/time.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/microdot/microdot.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def set_cookie(self, cookie, value, path=None, domain=None, expires=None,
if expires:
if isinstance(expires, str):
http_cookie += '; Expires=' + expires
else:
else: # pragma: no cover
http_cookie += '; Expires=' + time.strftime(
'%a, %d %b %Y %H:%M:%S GMT', expires.timetuple())
if max_age:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ def test_cookies(self):
res.set_cookie('foo2', 'bar2', path='/', partitioned=True)
res.set_cookie('foo3', 'bar3', domain='example.com:1234')
res.set_cookie('foo4', 'bar4',
expires=datetime(2019, 11, 5, 2, 23, 54))
expires='Tue, 05 Nov 2019 02:23:54 GMT')
res.set_cookie('foo5', 'bar5', max_age=123,
expires='Thu, 01 Jan 1970 00:00:00 GMT')
res.set_cookie('foo6', 'bar6', secure=True, http_only=True)
res.set_cookie('foo7', 'bar7', path='/foo', domain='example.com:1234',
expires=datetime(2019, 11, 5, 2, 23, 54), max_age=123,
expires='Tue, 05 Nov 2019 02:23:54 GMT', max_age=123,
secure=True, http_only=True)
res.delete_cookie('foo8', http_only=True)
self.assertEqual(res.headers, {'Set-Cookie': [
Expand Down
5 changes: 3 additions & 2 deletions tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
ARG VERSION=master
ENV VERSION=$VERSION

RUN apt-get update && \
apt-get install -y build-essential libffi-dev git pkg-config python3 && \
rm -rf /var/lib/apt/lists/* && \
git clone https://github.com/micropython/micropython.git && \
cd micropython && \
git checkout $VERSION && \
git submodule update --init && \
cd mpy-cross && \
make && \
cd .. && \
cd ports/unix && \
make && \
make test && \
make install && \
apt-get purge --auto-remove -y build-essential libffi-dev git pkg-config python3 && \
cd ../../.. && \
rm -rf micropython

CMD ["/usr/local/bin/micropython"]

24 changes: 24 additions & 0 deletions tools/Dockerfile.circuitpython
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
ARG VERSION=main
ENV VERSION=$VERSION

RUN apt-get update && \
apt-get install -y build-essential libffi-dev git pkg-config python3 && \
rm -rf /var/lib/apt/lists/* && \
git clone https://github.com/adafruit/circuitpython.git && \
cd circuitpython && \
git checkout $VERSION && \
git submodule update --init lib tools frozen && \
cd mpy-cross && \
make && \
cd .. && \
cd ports/unix && \
make && \
make install && \
apt-get purge --auto-remove -y build-essential libffi-dev git pkg-config python3 && \
cd ../../.. && \
rm -rf circuitpython

CMD ["/usr/local/bin/micropython"]
11 changes: 11 additions & 0 deletions tools/update-circuitpython.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# this script updates the micropython binary in the /bin directory that is
# used to run unit tests under GitHub Actions builds

DOCKER=${DOCKER:-docker}
VERSION=${1:-main}

$DOCKER build -f Dockerfile.circuitpython --build-arg VERSION=$VERSION -t circuitpython .
$DOCKER create -t --name dummy-circuitpython circuitpython
$DOCKER cp dummy-circuitpython:/usr/local/bin/micropython ../bin/circuitpython
$DOCKER rm dummy-circuitpython
3 changes: 2 additions & 1 deletion tools/update-micropython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# used to run unit tests under GitHub Actions builds

DOCKER=${DOCKER:-docker}
VERSION=${1:-master}

$DOCKER build -t micropython .
$DOCKER build --build-arg VERSION=$VERSION -t micropython .
$DOCKER create -it --name dummy-micropython micropython
$DOCKER cp dummy-micropython:/usr/local/bin/micropython ../bin/micropython
$DOCKER rm dummy-micropython
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist=flake8,py38,py39,py310,py311,py312,upy,benchmark
envlist=flake8,py38,py39,py310,py311,py312,upy,cpy,benchmark
skipsdist=True
skip_missing_interpreters=True

Expand Down Expand Up @@ -29,6 +29,10 @@ setenv=
allowlist_externals=sh
commands=sh -c "bin/micropython run_tests.py"

[testenv:cpy]
allowlist_externals=sh
commands=sh -c "bin/circuitpython run_tests.py"

[testenv:upy-mac]
allowlist_externals=micropython
commands=micropython run_tests.py
Expand Down

0 comments on commit f85a38c

Please sign in to comment.