cargo.port.mk: separate libtest argument namespace
Andrew Kloet <[email protected]> Wed, 05 Aug 2026 11:41:12 -0400
| Newsgroups | gmane.os.openbsd.tech |
|---|---|
| Message-ID | <[email protected]> |
--073ffc5e9d373eafc9840393ba887cfb8860c9b7d0354bd2bd34a946dbff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
Hello tech@
In net/arti I'd like to ignore a few tests that are expected to fail by
passing libtest arguments, for example:
MODCARGO_TEST_ARGS =3D -- --skip example_test
The `--` separator is required because `--skip` is a libtest option, not
a Cargo option [1]. With the current cargo.port.mk this cannot be done
when MODCARGO_FEATURES is also defined:
# User arguments for cargo targets.
MODCARGO_BUILD_ARGS ?=3D
MODCARGO_INSTALL_ARGS ?=3D
MODCARGO_TEST_ARGS ?=3D
# Manage crate features.
.if !empty(MODCARGO_FEATURES)
MODCARGO_BUILD_ARGS +=3D --features=3D'${MODCARGO_FEATURES}'
MODCARGO_INSTALL_ARGS +=3D --features=3D'${MODCARGO_FEATURES}'
MODCARGO_TEST_ARGS +=3D --features=3D'${MODCARGO_FEATURES}'
.endif
.if ${MODCARGO_NO_DEFAULT_FEATURES:L} =3D=3D "yes"
MODCARGO_BUILD_ARGS +=3D --no-default-features
MODCARGO_INSTALL_ARGS +=3D --no-default-features
MODCARGO_TEST_ARGS +=3D --no-default-features
.endif
cargo.port.mk appends `--features` and `--no-default-features` to
MODCARGO_TEST_ARGS. If MODCARGO_TEST_ARGS already contains `--`, those
options end up after the separator and are passed to libtest instead of
Cargo.
In brief: `MODCARGO_TEST_ARGS` is used for two different argument
namespaces: Cargo arguments and libtest arguments. There is currently
no way to pass arguments to libtest without also causing subsequent
Cargo arguments added by `cargo.port.mk` to be passed to libtest.
I propose that another variable, MODCARGO_LIBTEST_ARGS, be added.
[1] https://dirname.github.io/rust-std-doc/cargo/commands/cargo-test.html
Andrew
diff --git a/devel/cargo/cargo.port.mk b/devel/cargo/cargo.port.mk
index 0d63b67e6..a18d06d13 100644
--- a/devel/cargo/cargo.port.mk
+++ b/devel/cargo/cargo.port.mk
@@ -334,6 +334,7 @@ MODCARGO_CARGO_RUN =3D \
MODCARGO_BUILD_ARGS ?=3D
MODCARGO_INSTALL_ARGS ?=3D
MODCARGO_TEST_ARGS ?=3D
+MODCARGO_LIBTEST_ARGS ?=3D
=20
# Manage crate features.
.if !empty(MODCARGO_FEATURES)
@@ -396,7 +397,9 @@ MODCARGO_TEST_TARGET =3D \
${MODCARGO_CARGO_RUN} test \
--manifest-path ${MODCARGO_CARGOTOML} \
--release \
- ${MODCARGO_TEST_ARGS} ;
+ ${MODCARGO_TEST_ARGS} \
+ -- \
+ ${MODCARGO_LIBTEST_ARGS} ;
=20
.if !target(do-test) && ${MODCARGO_TEST:L} =3D=3D "yes"
do-test:
diff --git a/share/man/man5/cargo-module.5 b/share/man/man5/cargo-module.5
index 0c49e377a..ae7ecabd3 100644
--- a/share/man/man5/cargo-module.5
+++ b/share/man/man5/cargo-module.5
@@ -185,6 +185,8 @@ Defaults to
.It Ev MODCARGO_TEST_ARGS
Additional arguments passed to
.Cm cargo test .
+.It Ev MODCARGO_LIBTEST_ARGS
+Additional arguments passed to libtest.
.It Ev MODCARGO_CARGO_BIN
Path to the
.Xr cargo 1
--073ffc5e9d373eafc9840393ba887cfb8860c9b7d0354bd2bd34a946dbff
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQQDYAWAj/Md1ZRJrhK0H7x/oPHhDgUCanNZmAAKCRC0H7x/oPHh
DkWvAP40X9oxqLuwZL++n+trNOaay9GX4X66y1KKsWtatNVbiwD+M7O1ugXEqN8r
TqbZSsM3qqh6dB7UuA3G+IZkGHdZQQM=
=Lq0W
-----END PGP SIGNATURE-----
--073ffc5e9d373eafc9840393ba887cfb8860c9b7d0354bd2bd34a946dbff--