Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tools/tinytest-codegen, qemu-arm: Externalise tests list. #12859

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 1 commit into from
Nov 7, 2023

Conversation

agatti
Copy link
Contributor

@agatti agatti commented Nov 2, 2023

Tinytest code generation for bare-metal targets now allows to choose which port to generate tests for. Tinytest generation is not hardcoded to qemu-arm anymore, allowing more bare-metal targets to have their own tests.

The qemu-arm port was modified to work with the generator changes.

This is a slightly cleaned up version of what was originally part of #12853, and is required to have multiple bare-metal test targets (thus blocking #12853 once it is fully split up into smaller chunks like this one).

Copy link

github-actions bot commented Nov 2, 2023

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
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Merging #12859 (8916576) into master (06a7bf9) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master   #12859   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files         158      158           
  Lines       20973    20973           
=======================================
  Hits        20637    20637           
  Misses        336      336           

@agatti agatti force-pushed the port-specific-tinytest branch from 7ec2899 to bc84bce Compare November 2, 2023 14:11
@agatti agatti changed the title tools/tinytest-codegen, qemu-arm: Generate port-specific tests. tools/tinytest-codegen, qemu-arm: Externalise tests list. Nov 2, 2023
@agatti agatti force-pushed the port-specific-tinytest branch 3 times, most recently from edadfd5 to 343d319 Compare November 2, 2023 14:38
@agatti
Copy link
Contributor Author

agatti commented Nov 2, 2023

Apologies for the multiple forced pushes but turned out that my local precommit hooks were set up incorrectly and let through pretty much anything.

@@ -32,6 +32,35 @@ def script_to_map(test_file):
return r


def load_profile(profile_file):
Copy link
Member

Choose a reason for hiding this comment

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

Rather than writing a custom parser, what if the profiles were just Python code

def load_profile(profile_file):
  profile_globals = {"test_dirs": set(), "exclude_tests: set() }
  exec(profile_file, profile_globals)
  return profile_globals["test_dirs"], profile_globals["exclude_tests"]

Copy link
Member

Choose a reason for hiding this comment

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

This would allow you to write either:

test_dirs.add(...)

or

test_dirs = ...

in the profile script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just not really fond of exec myself, but your approach in this case makes more sense if test_dirs and exclude_tests are pre-populated with the default lists. This way one may not only add new entries but delete ones that aren't relevant for a particular port (or add conditional exclusions if some environment variables set by make are passed down to the configuration script, like the board name for instance).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, if the global test_dirs and exclude_tests variables are filtered through the configuration script rather than composed from the configuration script output it also resolves the nomenclature remark. The global variables get reassigned from the output of load_profile so no new variables are defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've switched to a Python script as a configuration file. I wonder whether I should change the configuration script extension to .py and let ruff skip error F821 on that file as well in pyproject.toml (or maybe use ports/**/tests_profile.py?)

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to leave it as a .txt.

@agatti agatti force-pushed the port-specific-tinytest branch from 343d319 to 8916576 Compare November 2, 2023 23:46
@dpgeorge dpgeorge added the tools Relates to tools/ directory in source, or other tooling label Nov 3, 2023
Remove port-specific test directories and excluded tests from
tinytest-codegen, and let it read said information from an external file.
This way tinytest-codegen is not limited to always generate tests for the
`qemu-arm` target.

This allows having port-specific test directory and excluded tests for more
than one QEMU bare-metal target.

The `qemu-arm` port Makefile was modified to work with the generator
changes and a tests profile file was added to said port.

Signed-off-by: Alessandro Gatti <[email protected]>
@dpgeorge dpgeorge force-pushed the port-specific-tinytest branch from 8916576 to bea6ff8 Compare November 7, 2023 04:56
@dpgeorge dpgeorge merged commit bea6ff8 into micropython:master Nov 7, 2023
@dpgeorge
Copy link
Member

dpgeorge commented Nov 7, 2023

Thanks for this, it's a nice generalisation.

@agatti agatti deleted the port-specific-tinytest branch November 7, 2023 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Relates to tools/ directory in source, or other tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants