1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-21 22:08:08 +00:00

feat(tests): generate master diff for subset of models

This commit is contained in:
Martin Milata 2023-12-08 16:49:07 +01:00
parent 1c0da78536
commit cd7899dbcc
3 changed files with 15 additions and 7 deletions

View File

@ -9,8 +9,9 @@ def cli():
@cli.command(name="master-diff") @cli.command(name="master-diff")
def do_master_diff(): @click.argument("models", nargs=-1)
master_diff.main() def do_master_diff(models: list[str] | None = None):
master_diff.main(models=models)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -36,7 +36,9 @@ def generate_master_diff_report(
def get_diff( def get_diff(
current: FixturesType, print_to_console: bool = False current: FixturesType,
print_to_console: bool = False,
models: list[str] | None = None,
) -> tuple[dict[str, str], dict[str, str], dict[str, tuple[str, str]]]: ) -> tuple[dict[str, str], dict[str, str], dict[str, tuple[str, str]]]:
master = _get_preprocessed_master_fixtures() master = _get_preprocessed_master_fixtures()
@ -45,6 +47,9 @@ def get_diff(
diff = {} diff = {}
for model in master.keys() | current.keys(): for model in master.keys() | current.keys():
if models and model not in models:
continue
master_groups = master.get(model, {}) master_groups = master.get(model, {})
current_groups = current.get(model, {}) current_groups = current.get(model, {})
for group in master_groups.keys() | current_groups.keys(): for group in master_groups.keys() | current_groups.keys():

View File

@ -104,9 +104,11 @@ def create_dirs() -> None:
IMAGES_PATH.mkdir(exist_ok=True) IMAGES_PATH.mkdir(exist_ok=True)
def create_reports() -> None: def create_reports(models: list[str] | None = None) -> None:
current = get_current_fixtures() current = get_current_fixtures()
removed_tests, added_tests, diff_tests = get_diff(current, print_to_console=True) removed_tests, added_tests, diff_tests = get_diff(
current, print_to_console=True, models=models
)
@contextmanager @contextmanager
def tmpdir(): def tmpdir():
@ -131,8 +133,8 @@ def create_reports() -> None:
generate_master_diff_report(diff_tests, MASTERDIFF_PATH) generate_master_diff_report(diff_tests, MASTERDIFF_PATH)
def main() -> None: def main(models: list[str] | None = None) -> None:
create_dirs() create_dirs()
html.set_image_dir(IMAGES_PATH) html.set_image_dir(IMAGES_PATH)
create_reports() create_reports(models)
index() index()