Skip to content

tests: improve autodetection of target features and simplify how tests are selected #17880

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
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
1 change: 1 addition & 0 deletions .github/workflows/ports_webassembly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'shared/**'
- 'lib/**'
- 'ports/webassembly/**'
- 'tests/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ports_zephyr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'shared/**'
- 'lib/**'
- 'ports/zephyr/**'
- 'tests/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
5 changes: 5 additions & 0 deletions ports/webassembly/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
// the top-level call into C.
static size_t external_call_depth = 0;

// Emscripten defaults to a 64k C-stack, so our limit should be less than that.
#define CSTACK_SIZE (32 * 1024)

#if MICROPY_GC_SPLIT_HEAP_AUTO
static void gc_collect_top_level(void);
#endif
Expand All @@ -67,6 +70,8 @@ void external_call_depth_dec(void) {
}

void mp_js_init(int pystack_size, int heap_size) {
mp_cstack_init_with_sp_here(CSTACK_SIZE);

#if MICROPY_ENABLE_PYSTACK
mp_obj_t *pystack = (mp_obj_t *)malloc(pystack_size * sizeof(mp_obj_t));
mp_pystack_init(pystack, pystack + pystack_size);
Expand Down
1 change: 0 additions & 1 deletion ports/webassembly/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#define MICROPY_READER_VFS (MICROPY_VFS)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_PYSTACK (1)
#define MICROPY_STACK_CHECK (0)
#define MICROPY_KBD_EXCEPTION (1)
#define MICROPY_REPL_EVENT_DRIVEN (1)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
Expand Down
6 changes: 3 additions & 3 deletions tests/basics/io_buffered_writer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import io

try:
import io

io.BytesIO
io.BufferedWriter
except AttributeError:
except (AttributeError, ImportError):
print('SKIP')
raise SystemExit

Expand Down
8 changes: 7 additions & 1 deletion tests/basics/io_bytesio_cow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Make sure that write operations on io.BytesIO don't
# change original object it was constructed from.
import io

try:
import io
except ImportError:
print("SKIP")
raise SystemExit

b = b"foobar"

a = io.BytesIO(b)
Expand Down
8 changes: 7 additions & 1 deletion tests/basics/io_bytesio_ext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Extended stream operations on io.BytesIO
import io

try:
import io
except ImportError:
print("SKIP")
raise SystemExit

a = io.BytesIO(b"foobar")
a.seek(10)
print(a.read(10))
Expand Down
7 changes: 6 additions & 1 deletion tests/basics/io_bytesio_ext2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit

a = io.BytesIO(b"foobar")
try:
a.seek(-10)
Expand Down
7 changes: 4 additions & 3 deletions tests/basics/io_iobase.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import io
try:
import io

io.IOBase
except AttributeError:
print('SKIP')
except (AttributeError, ImportError):
print("SKIP")
raise SystemExit


Expand Down
7 changes: 6 additions & 1 deletion tests/basics/io_stringio1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit

a = io.StringIO()
print('io.StringIO' in repr(a))
print(a.getvalue())
Expand Down
6 changes: 5 additions & 1 deletion tests/basics/io_stringio_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Checks that an instance type inheriting from a native base that uses
# MP_TYPE_FLAG_ITER_IS_STREAM will still have a getiter.

import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit

a = io.StringIO()
a.write("hello\nworld\nmicro\npython\n")
Expand Down
7 changes: 6 additions & 1 deletion tests/basics/io_stringio_with.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import io
try:
import io
except ImportError:
print("SKIP")
raise SystemExit

# test __enter__/__exit__
with io.StringIO() as b:
b.write("foo")
Expand Down
5 changes: 3 additions & 2 deletions tests/basics/io_write_ext.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# This tests extended (MicroPython-specific) form of write:
# write(buf, len) and write(buf, offset, len)
import io

try:
import io

io.BytesIO
except AttributeError:
except (AttributeError, ImportError):
print('SKIP')
raise SystemExit

Expand Down
13 changes: 0 additions & 13 deletions tests/feature_check/float.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/feature_check/float.py.exp

This file was deleted.

6 changes: 0 additions & 6 deletions tests/feature_check/io_module.py

This file was deleted.

Empty file.
13 changes: 12 additions & 1 deletion tests/feature_check/target_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,15 @@
][sys_mpy >> 10]
thread = getattr(sys.implementation, "_thread", None)

print(platform, arch, thread)
# Detect how many bits of precision the floating point implementation has.
try:
if float("1.0000001") == float("1.0"):
float_prec = 30
elif float("1e300") == float("inf"):
float_prec = 32
else:
float_prec = 64
except NameError:
float_prec = 0

print(platform, arch, thread, float_prec, len("α") == 1)
Loading
Loading