cl: test drops a caller's --message-format (cl reads cargo's JSON messages itself)

This commit is contained in:
aiongg
2026-11-15 21:35:00 +00:00
parent a83b8e9ce7
commit 86efb4973c
+11 -1
View File
@@ -303,7 +303,17 @@ def test(top, packages, cargo_args, test_args):
directory, the lib's unit tests first, stopping at the first that fails."""
no_run = "--no-run" in cargo_args
quiet = "-q" in cargo_args or "--quiet" in cargo_args
cargo_args = [a for a in cargo_args if a != "--no-run"]
# cl reads cargo's JSON messages itself (diagnostics still render), so a caller's own --message-format is dropped.
kept = []
skip = False
for a in cargo_args:
if skip:
skip = False
elif a == "--message-format":
skip = True
elif a != "--no-run" and not a.startswith("--message-format="):
kept.append(a)
cargo_args = kept
rc, target, messages = cargo(top, cargo_args[:1] + ["--no-run", "--message-format=json-render-diagnostics"] + cargo_args[1:], json_out=True)
if rc != 0:
sys.exit(rc)