Fix positioning of cargoExtraArgs in craneLib.cargoNextest (#678)

Both `cargo nextest run` and `cargo llvm-cov` do not place any cargo
options/flags right behind `cargo <HERE> ...`. All cargo related flags
can be added to the `cargoNextestExtraArgs` attribute. [Issue #675]

After altering `checkPhaseCargoCommand` to use one of two explicit
command strings inside if/else blocks, it is no longer necessary to
default `cmd` to an empty value when `withLlvmCov` is set to `true`.

---------

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
This commit is contained in:
Nils Harbke 2024-08-06 16:07:59 +00:00 committed by GitHub
parent d0c8f4ed85
commit 4c6c77920b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
* Fixed vendoring dependencies from an alternative registry which they
themselves have dependencies on crates from _other_ registries.
* Fixed `cargoNextest`'s positioning of `cargoExtraArgs` to form a valid command
invocation when specified.
## [0.18.0] - 2024-07-05

View File

@ -624,6 +624,7 @@ Except where noted below, all derivation attributes are delegated to
* `cargoNextestExtraArgs`: additional flags to be passed in the nextest invocation
(e.g. specifying a profile)
- Default value: `""`
- Note that all flags from `cargo test` are supported.
* `partitions`: The number of separate nextest partitions to run. Useful if the
test suite takes a long time and can be parallelized across multiple build
nodes.

View File

@ -27,7 +27,7 @@ let
"withLlvmCov"
];
mkUpdatedArgs = { cmd ? lib.optionalString (!withLlvmCov) "run", extraSuffix ? "", moreArgs ? "", withLlvmCov }: args // {
mkUpdatedArgs = { cmd ? "run", extraSuffix ? "", moreArgs ? "", withLlvmCov }: args // {
inherit cargoArtifacts;
pnameSuffix = "-nextest${extraSuffix}";
doCheck = args.doCheck or true;
@ -44,10 +44,11 @@ let
'';
checkPhaseCargoCommand = ''
cargo ${cargoExtraArgs} \
${lib.optionalString withLlvmCov "llvm-cov ${cargoLlvmCovExtraArgs}"} \
nextest ${cmd} ''${CARGO_PROFILE:+--cargo-profile $CARGO_PROFILE} \
${cargoNextestExtraArgs} ${moreArgs}
${if withLlvmCov
then "cargo llvm-cov nextest ${cargoLlvmCovExtraArgs}"
else "cargo nextest ${cmd}"} \
''${CARGO_PROFILE:+--cargo-profile $CARGO_PROFILE} \
${cargoExtraArgs} ${cargoNextestExtraArgs} ${moreArgs}
'';
nativeBuildInputs = (args.nativeBuildInputs or [ ])