Skip to content

Commit a8a240b

Browse files
committed
test: add support for running commands with nightly toolchain
Add a `nightly` flag to the `cargo` function, which causes the requested command to be executing using the nightly toolchain. We have a nightly toolchain in our container due to kani. But since the toolchain version is prescribed by kani, we need to dynamically determine its name from `rustup toolchain list`, and cannot just use `+nightly`. Signed-off-by: Patrick Roy <[email protected]>
1 parent 77d3704 commit a8a240b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/host_tools/cargo_build.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,27 @@
1414
DEFAULT_TARGET_DIR = f"{DEFAULT_TARGET}/release/"
1515

1616

17+
def nightly_toolchain() -> str:
18+
"""Receives the name of the installed nightly toolchain"""
19+
return utils.check_output("rustup toolchain list | grep nightly").stdout.strip()
20+
21+
1722
def cargo(
1823
subcommand,
1924
cargo_args: str = "",
2025
subcommand_args: str = "",
2126
*,
2227
env: dict = None,
2328
cwd: str = None,
29+
nightly: bool = False,
2430
):
2531
"""Executes the specified cargo subcommand"""
32+
toolchain = f"+{nightly_toolchain()}" if nightly else ""
2633
env = env or {}
2734
env_string = " ".join(f'{key}="{str(value)}"' for key, value in env.items())
28-
cmd = f"{env_string} cargo {subcommand} {cargo_args} -- {subcommand_args}"
35+
cmd = (
36+
f"{env_string} cargo {toolchain} {subcommand} {cargo_args} -- {subcommand_args}"
37+
)
2938
return utils.check_output(cmd, cwd=cwd)
3039

3140

0 commit comments

Comments
 (0)