def calc_steps()

in automation/tests.py [0:0]


def calc_steps(args):
    """
    Calculate the steps needed to run the tests

    Yields a list of (name, func) items.
    """
    if args.mode == "changes":
        # changes mode is complicated enough that it's split off into its own
        # function
        for step in calc_steps_change_mode(args):
            yield step
    elif args.mode == "rust-tests":
        print_rust_environment()
        yield Step("cargo clean", cargo_clean)
        for package, features in calc_rust_items():
            if should_run_rust_tests(package, False):
                yield Step(
                    f"tests for {package.name} ({features.label()})",
                    run_rust_test,
                    package,
                    features,
                )
    elif args.mode == "rust-min-version-tests":
        print_rust_environment()
        yield Step("cargo clean", cargo_clean)
        for package, features in calc_rust_items():
            if should_run_rust_tests(package, True):
                yield Step(
                    f"tests for {package.name} ({features.label()})",
                    run_rust_test,
                    package,
                    features,
                )
    elif args.mode == "rust-clippy":
        print_rust_environment()
        yield Step("cargo clean", cargo_clean)
        for package, features in calc_rust_items():
            yield Step(
                f"clippy for {package.name} ({features.label()})",
                run_clippy,
                package,
                features,
            )
        # non-workspace items aren't tested, but we do run clippy on them to
        # make sure they don't go stale.
        for package, features in calc_non_workspace_rust_items():
            yield Step(
                f"clippy for {package.name} ({features.label()})",
                run_clippy,
                package,
                features,
            )
    elif args.mode == "rust-fmt":
        print_rust_environment()
        yield Step("cargo fmt", cargo_fmt)
    elif args.mode == "ktlint":
        yield Step("ktlint", run_ktlint)
    elif args.mode == "swiftlint":
        yield Step("swiftlint", run_swiftlint)
    elif args.mode == "swiftformat":
        yield Step("swiftformat", swift_format)
    elif args.mode == "nss-bindings":
        print_rust_environment()
        yield Step("NSS bindings test", run_nss_bindings_test)
    elif args.mode == "gradle":
        yield Step("gradle tests", run_gradle_tests)
    elif args.mode == "ios-tests":
        yield Step("ios tests", run_ios_tests)
    elif args.mode == "python-tests":
        yield Step("python tests", run_python_tests)
    else:
        print(f"Invalid mode: {args.mode}")
        sys.exit(1)