Skip to content

Commit

Permalink
Fix positioning of cargoExtraArgs in craneLib.cargoNextest (#678)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
skarmux and ipetkov authored Aug 6, 2024
1 parent d0c8f4e commit 4c6c779
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions lib/cargoNextest.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 [ ])
Expand Down

0 comments on commit 4c6c779

Please sign in to comment.