-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
Code size report:
|
Codecov Report
@@ Coverage Diff @@
## master #12859 +/- ##
=======================================
Coverage 98.39% 98.39%
=======================================
Files 158 158
Lines 20973 20973
=======================================
Hits 20637 20637
Misses 336 336 |
7ec2899
to
bc84bce
Compare
edadfd5
to
343d319
Compare
Apologies for the multiple forced pushes but turned out that my local precommit hooks were set up incorrectly and let through pretty much anything. |
tools/tinytest-codegen.py
Outdated
@@ -32,6 +32,35 @@ def script_to_map(test_file): | |||
return r | |||
|
|||
|
|||
def load_profile(profile_file): |
There was a problem hiding this comment.
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"]
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?)
There was a problem hiding this comment.
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
.
343d319
to
8916576
Compare
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]>
8916576
to
bea6ff8
Compare
Thanks for this, it's a nice generalisation. |
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).