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

Conversation

dpgeorge
Copy link
Member

@dpgeorge dpgeorge commented Aug 11, 2025

Summary

There are five changes in this PR, all aimed to automate, simplify and generalise which tests are run on a given target:

  1. automatically include float/ tests if the target supports floating point
  • this removes the code which explicitly adds this test directory for certain targets
  • it also means the tests won't be added incorrectly, eg on a unix build without float
  1. always include stress/ tests
  • this simplifies the customisation of which tests to run
  • stress tests are now run on all targets, improving test coverage
  1. generalise addition of port specific test directory
  • no more explicit code to add, eg, ports/stm32 to the list of test dirs; it's now done in a general way based on sys.platform
  1. autodetect if the target has unicode support
  • a simple piece of code is added to target_info.py to detect unicode support
  • unicode tests are now run on all targets (previously only run on unix) which improves test coverage
  • other unicode tests (such as extmod/json_loads.py) are now properly skipped if the target doesn't have unicode support
  1. skip basics/io_*.py tests using the SKIP mechanism, rather than having a feature test for the io module
  • this is consistent with how all other tests for optional modules are skipped

EDIT: I added a 6th commit, to enable C-stack checking on the webassembly port. That's needed for it to pass the now-enabled stress tests on this port. This is definitely an improvement to this port, otherwise users get strange Wasm errors if they overflow the C stack.

Testing

Tested locally on unix, webassembly, qemu, PYBD_SF6 and ADAFRUIT_ITSYBITSY_M0_EXPRESS.

Will also be tested by CI.

Trade-offs and Alternatives

This should be a win all round, to simplify run-tests.py and improve test coverage.

It will also help with Octoprobe, to get more tests passing there (it tests a lot of different configurations, especially smaller targets without unicode).

@dpgeorge dpgeorge added the tests Relates to tests/ directory in source label Aug 11, 2025
@dpgeorge dpgeorge force-pushed the tests-run-tests-more-auto-detection-of-test-dirs branch from 0d5f468 to a0b9c6e Compare August 11, 2025 02:27
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@dpgeorge dpgeorge requested a review from projectgus August 11, 2025 03:51
Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like good simplifications to me!

This simplifies the code by removing the explicit addition of the "float/"
test directory for certain targets.  It also means the tests won't be added
incorrectly, eg on a unix build without float.

Signed-off-by: Damien George <damien@micropython.org>
Ports that now run the stress tests, that didn't prior to this commit are:
cc3200, esp8266, minimal, nrf, renesas-ra, samd, qemu, webassembly.

Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
The unicode tests are now run on all targets that enable unicode.  And
other unicode tests (namely `extmod/json_loads.py`) are now properly
skipped if the target doesn't have unicode support.

Signed-off-by: Damien George <damien@micropython.org>
Instead of using a feature check.  This is more consistent with how other
optional modules are skipped.

Signed-off-by: Damien George <damien@micropython.org>
Because these ports run tests as part of CI, and need to be run if any of
the tests change, to check those changes.

Signed-off-by: Damien George <damien@micropython.org>
This gets the recursive stress-tests working on this port.

For relatively small Python functions the maximum recursive depth is about
150 nested calls.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the tests-run-tests-more-auto-detection-of-test-dirs branch from 0271a61 to c16fe5b Compare August 14, 2025 14:24
@dpgeorge dpgeorge merged commit c16fe5b into micropython:master Aug 14, 2025
71 checks passed
@dpgeorge dpgeorge deleted the tests-run-tests-more-auto-detection-of-test-dirs branch August 14, 2025 14:30
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (744270a) to head (c16fe5b).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17880   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22295    22295           
=======================================
  Hits        21936    21936           
  Misses        359      359           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Relates to tests/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants