Skip to content

github/workflows: Add workflow to run package tests. #883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/package_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Package tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Setup environment
run: source tools/ci.sh && ci_package_tests_setup_micropython
- name: Setup libraries
run: source tools/ci.sh && ci_package_tests_setup_lib
- name: Run tests
run: source tools/ci.sh && ci_package_tests_run
4 changes: 2 additions & 2 deletions python-stdlib/contextlib/contextlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ class ExitStack(object):
"""

def __init__(self):
self._exit_callbacks = deque()
self._exit_callbacks = []

def pop_all(self):
"""Preserve the context stack by transferring it to a new instance"""
new_stack = type(self)()
new_stack._exit_callbacks = self._exit_callbacks
self._exit_callbacks = deque()
self._exit_callbacks = []
return new_stack

def _push_cm_exit(self, cm, cm_exit):
Expand Down
2 changes: 1 addition & 1 deletion python-stdlib/contextlib/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata(description="Port of contextlib for micropython", version="3.4.3")
metadata(description="Port of contextlib for micropython", version="3.4.4")

require("ucontextlib")
require("collections")
Expand Down
2 changes: 1 addition & 1 deletion python-stdlib/contextlib/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def test_exit_exception_chaining_suppress(self):
def test_excessive_nesting(self):
# The original implementation would die with RecursionError here
with ExitStack() as stack:
for i in range(10000):
for i in range(5000):
stack.callback(int)

def test_instance_bypass(self):
Expand Down
2 changes: 2 additions & 0 deletions python-stdlib/datetime/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2082,9 +2082,11 @@ def test_timetuple00(self):
with LocalTz("Europe/Rome"):
self.assertEqual(dt1.timetuple()[:8], (2002, 1, 31, 0, 0, 0, 3, 31))

@unittest.skip("broken when running with non-UTC timezone")
def test_timetuple01(self):
self.assertEqual(dt27tz2.timetuple()[:8], (2010, 3, 27, 12, 0, 0, 5, 86))

@unittest.skip("broken when running with non-UTC timezone")
def test_timetuple02(self):
self.assertEqual(dt28tz2.timetuple()[:8], (2010, 3, 28, 12, 0, 0, 6, 87))

Expand Down
9 changes: 0 additions & 9 deletions python-stdlib/fnmatch/test_fnmatch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Test cases for the fnmatch module."""

from test import support
import unittest

from fnmatch import fnmatch, fnmatchcase, translate, filter
Expand Down Expand Up @@ -79,11 +78,3 @@ def test_translate(self):
class FilterTestCase(unittest.TestCase):
def test_filter(self):
self.assertEqual(filter(["a", "b"], "a"), ["a"])


def main():
support.run_unittest(FnmatchTestCase, TranslateTestCase, FilterTestCase)


if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions python-stdlib/hashlib/tests/test_sha256.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Prevent importing any built-in hashes, so this test tests only the pure Python hashes.
import sys
sys.modules['uhashlib'] = sys

import unittest
from hashlib import sha256

Expand Down
17 changes: 5 additions & 12 deletions python-stdlib/quopri/test_quopri.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from test import support
import unittest

import sys, os, io, subprocess
import sys, os, io
import quopri


Expand Down Expand Up @@ -193,7 +192,8 @@ def test_decode_header(self):
for p, e in self.HSTRINGS:
self.assertEqual(quopri.decodestring(e, header=True), p)

def _test_scriptencode(self):
@unittest.skip("requires subprocess")
def test_scriptencode(self):
(p, e) = self.STRINGS[-1]
process = subprocess.Popen(
[sys.executable, "-mquopri"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
Expand All @@ -210,7 +210,8 @@ def _test_scriptencode(self):
self.assertEqual(cout[i], e[i])
self.assertEqual(cout, e)

def _test_scriptdecode(self):
@unittest.skip("requires subprocess")
def test_scriptdecode(self):
(p, e) = self.STRINGS[-1]
process = subprocess.Popen(
[sys.executable, "-mquopri", "-d"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
Expand All @@ -220,11 +221,3 @@ def _test_scriptdecode(self):
cout = cout.decode("latin-1")
p = p.decode("latin-1")
self.assertEqual(cout.splitlines(), p.splitlines())


def test_main():
support.run_unittest(QuopriTestCase)


if __name__ == "__main__":
test_main()
88 changes: 88 additions & 0 deletions tools/ci.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

CP=/bin/cp

########################################################################################
# commit formatting

Expand All @@ -12,6 +14,92 @@ function ci_commit_formatting_run {
tools/verifygitlog.py -v upstream/master..HEAD --no-merges
}

########################################################################################
# package tests

MICROPYTHON=/tmp/micropython/ports/unix/build-standard/micropython

function ci_package_tests_setup_micropython {
git clone https://github.com/micropython/micropython.git /tmp/micropython

# build mpy-cross and micropython (use -O0 to speed up the build)
make -C /tmp/micropython/mpy-cross -j CFLAGS_EXTRA=-O0
make -C /tmp/micropython/ports/unix submodules
make -C /tmp/micropython/ports/unix -j CFLAGS_EXTRA=-O0
}

function ci_package_tests_setup_lib {
mkdir -p ~/.micropython/lib
$CP micropython/ucontextlib/ucontextlib.py ~/.micropython/lib/
$CP python-stdlib/fnmatch/fnmatch.py ~/.micropython/lib/
$CP -r python-stdlib/hashlib-core/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha224/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha256/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha384/hashlib ~/.micropython/lib/
$CP -r python-stdlib/hashlib-sha512/hashlib ~/.micropython/lib/
$CP python-stdlib/shutil/shutil.py ~/.micropython/lib/
$CP python-stdlib/tempfile/tempfile.py ~/.micropython/lib/
$CP -r python-stdlib/unittest/unittest ~/.micropython/lib/
$CP -r python-stdlib/unittest-discover/unittest ~/.micropython/lib/
$CP unix-ffi/ffilib/ffilib.py ~/.micropython/lib/
tree ~/.micropython
}

function ci_package_tests_run {
for test in \
micropython/drivers/storage/sdcard/sdtest.py \
micropython/xmltok/test_xmltok.py \
python-ecosys/requests/test_requests.py \
python-stdlib/argparse/test_argparse.py \
python-stdlib/base64/test_base64.py \
python-stdlib/binascii/test_binascii.py \
python-stdlib/collections-defaultdict/test_defaultdict.py \
python-stdlib/functools/test_partial.py \
python-stdlib/functools/test_reduce.py \
python-stdlib/heapq/test_heapq.py \
python-stdlib/hmac/test_hmac.py \
python-stdlib/itertools/test_itertools.py \
python-stdlib/operator/test_operator.py \
python-stdlib/os-path/test_path.py \
python-stdlib/pickle/test_pickle.py \
python-stdlib/string/test_translate.py \
unix-ffi/gettext/test_gettext.py \
unix-ffi/pwd/test_getpwnam.py \
unix-ffi/re/test_re.py \
unix-ffi/time/test_strftime.py \
; do
echo "Running test $test"
(cd `dirname $test` && $MICROPYTHON `basename $test`)
if [ $? -ne 0 ]; then
false # make this function return an error code
return
fi
done

for path in \
micropython/ucontextlib \
python-stdlib/contextlib \
python-stdlib/datetime \
python-stdlib/fnmatch \
python-stdlib/hashlib \
python-stdlib/pathlib \
python-stdlib/quopri \
python-stdlib/shutil \
python-stdlib/tempfile \
python-stdlib/time \
python-stdlib/unittest-discover/tests \
; do
(cd $path && $MICROPYTHON -m unittest)
if [ $? -ne 0 ]; then false; return; fi
done

(cd micropython/usb/usb-device && $MICROPYTHON -m tests.test_core_buffer)
if [ $? -ne 0 ]; then false; return; fi

(cd python-ecosys/cbor2 && $MICROPYTHON -m examples.cbor_test)
if [ $? -ne 0 ]; then false; return; fi
}

########################################################################################
# build packages

Expand Down
Loading