def calc_rust_items()

in automation/tests.py [0:0]


def calc_rust_items(branch_changes=None, default_features_only=False):
    """
    Calculate which items we want to test and run clippy on

    Args:
        branch_changes: only yield items for rust packages that have changes
        default_features_only: only test with the default features

    Returns: list of (RustPackage, RustFeatures) items
    """
    json_data = json.loads(
        get_output(
            [
                "cargo",
                "metadata",
                "--no-deps",
                "--format-version",
                "1",
            ]
        )
    )

    packages = [RustPackage(p) for p in json_data["packages"]]

    if branch_changes:
        packages = [p for p in packages if p.has_changes(branch_changes)]

    for p in packages:
        yield p, RustFeatures.DEFAULT

    if default_features_only:
        return

    for p in packages:
        if p.has_features():
            yield p, RustFeatures.ALL
    for p in packages:
        if p.has_default_features():
            yield p, RustFeatures.NONE