Test executor
These modules run before a test. collect selects which tests to run, and
context builds the test configuration from its config.toml, overwriting
from the provided context, for example, the git reference to get the artifacts
from or explicit board to run the test on.
Context
Prepare context for a test from tests/**/.
Input: Test to run:
{
"name": "demo/linux-iio-dac",
"repository": {
"linux": {"ref": "010c31d..."}
}
}
From the config.toml files, [[repository]] is parsed as:
{..., 'repository': [{'name': 'linux', 'ref': 'refs/heads/main', 'files': '...'}]}
It is reformatted to:
{..., 'repository': {'linux': {'ref': 'refs/heads/main', 'files': '...'}}}
before merging into the context.
That is, any [{'name': '...', ...}] list is replaced with a dict,
where name is the key (and must exist for each group/list entry).
- hw_tests.context.reformat_named_lists(d)
Reformat any list-of-dicts-with-‘name’ into a dict keyed by name.
- e.g. [{‘name’: ‘linux’, ‘ref’: ‘…’}, {‘name’: ‘hdl’, ‘ref’: ‘…’}]
-> {‘linux’: {‘ref’: ‘…’}, ‘hdl’: {‘ref’: ‘…’}}
- hw_tests.context.deep_merge(base, override)
Return
baseupdated withoverride, merging nested dicts.
Collect
Match workflow-run-to-context output against tests/**/config.toml metafiles.
Input: JSON by workflow-run-to-context@action, e.g.:
{
"repository": "linux",
"head_sha": "010c31d...",
"changed_files": "drivers/iio/dac/Kconfig\ndrivers/iio/dac/ad3530r.c",
...
}
Output: JSON list written to <output_path> (or stdout), one entry per matched test:
[
{
"name": "demo/linux-iio-dac",
"with": {
"linux": {"ref": "010c31d..."}, <- merge_commit_sha || head_sha: this repo triggered
}
}
]
- hw_tests.collect.paths_match(changed_files, path_block)
Return True if any changed file matches any glob pattern in path_block.