Skip to content

Commit 6ff8baa

Browse files
committed
Fix CI bootstrap and cargo install fallback
Signed-off-by: Nick Sweeting <git@sweeting.me>
1 parent c6c886a commit 6ff8baa

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

abxpkg/binprovider_cargo.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ def default_install_handler(
167167
cmd=["install", *cargo_install_args, *install_args],
168168
timeout=timeout,
169169
)
170+
proc_output = format_subprocess_output(proc.stdout, proc.stderr)
171+
if (
172+
proc.returncode != 0
173+
and "--locked" in cargo_install_args
174+
and "lock file version 4 requires `-Znext-lockfile-bump`" in proc_output
175+
):
176+
proc = self.exec(
177+
bin_name=installer_bin,
178+
cmd=["install", *cargo_install_args[1:], *install_args],
179+
timeout=timeout,
180+
)
170181
if proc.returncode != 0:
171182
self._raise_proc_error("install", install_args, proc)
172183
return format_subprocess_output(proc.stdout, proc.stderr)
@@ -202,6 +213,22 @@ def default_update_handler(
202213
],
203214
timeout=timeout,
204215
)
216+
proc_output = format_subprocess_output(proc.stdout, proc.stderr)
217+
if (
218+
proc.returncode != 0
219+
and "--locked" in cargo_install_args
220+
and "lock file version 4 requires `-Znext-lockfile-bump`" in proc_output
221+
):
222+
proc = self.exec(
223+
bin_name=installer_bin,
224+
cmd=[
225+
"install",
226+
"--force",
227+
*cargo_install_args[1:],
228+
*install_args,
229+
],
230+
timeout=timeout,
231+
)
205232
if proc.returncode != 0:
206233
self._raise_proc_error("update", install_args, proc)
207234
return format_subprocess_output(proc.stdout, proc.stderr)

tests/conftest.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
import shutil
45
import subprocess
56
from pathlib import Path
@@ -86,18 +87,27 @@ def _ensure_test_machine_dependencies() -> None:
8687
class TestMachine:
8788
def require_tool(self, tool_name: str) -> str:
8889
tool_path = shutil.which(tool_name)
89-
if not tool_path and tool_name == "cargo":
90+
if not tool_path:
9091
proc = subprocess.run(
9192
[
9293
str(_abxpkg_executable()),
9394
"--lib=None",
9495
"install",
96+
"--abspath",
9597
tool_name,
9698
],
9799
capture_output=True,
98100
text=True,
101+
env={
102+
**os.environ,
103+
"NO_COLOR": "1",
104+
"TERM": "dumb",
105+
},
99106
)
100-
tool_path = shutil.which(tool_name)
107+
output_lines = [
108+
line.strip() for line in proc.stdout.splitlines() if line.strip()
109+
]
110+
tool_path = output_lines[-1] if output_lines else shutil.which(tool_name)
101111
assert proc.returncode == 0 and tool_path, (
102112
f"{tool_name} is required on this host for test-machine integration tests, "
103113
f"and fallback install via abxpkg failed.\n"

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ def test_activate_command_rejects_multiple_shell_modes():
10431043
)
10441044

10451045
assert result.exit_code != 0
1046-
assert "choose only one of --bash, --zsh, or --fish" in result.output
1046+
assert "choose only one of --bash, --zsh, or --fish" in click.unstyle(result.output)
10471047

10481048

10491049
def test_exec_command_hidden_alias_runs_like_run():

0 commit comments

Comments
 (0)