Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tests/host_tools/cargo_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@
DEFAULT_TARGET_DIR = f"{DEFAULT_TARGET}/release/"


def nightly_toolchain() -> str:
"""Receives the name of the installed nightly toolchain"""
return utils.check_output("rustup toolchain list | grep nightly").stdout.strip()


def cargo(
subcommand,
cargo_args: str = "",
subcommand_args: str = "",
*,
env: dict = None,
cwd: str = None,
nightly: bool = False,
):
"""Executes the specified cargo subcommand"""
toolchain = f"+{nightly_toolchain()}" if nightly else ""
env = env or {}
env_string = " ".join(f'{key}="{str(value)}"' for key, value in env.items())
cmd = f"{env_string} cargo {subcommand} {cargo_args} -- {subcommand_args}"
cmd = (
f"{env_string} cargo {toolchain} {subcommand} {cargo_args} -- {subcommand_args}"
)
return utils.check_output(cmd, cwd=cwd)


Expand Down
12 changes: 12 additions & 0 deletions tests/integration_tests/build/test_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""Enforces controls over dependencies."""

from host_tools.cargo_build import cargo


def test_unused_dependencies():
"""
Test that there are no unused dependencies.
"""
cargo("udeps", "--all", nightly=True)
Loading