Skip to content

Add workaround for cargo-nextest bug #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
`Cargo.lock` is exactly what is expected (without implicit changes at build
time) but this may end up rejecting builds which were previously passing. To
get the old behavior back, set `cargoExtraArgs = "";`
* Fixed a bug when testing proc macro crates with `cargoNextest` on macO. ([#376](https://github.com/ipetkov/crane/pull/376))

## [0.13.1] - 2023-08-22

Expand Down
4 changes: 4 additions & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ in

nextest = callPackage ./nextest.nix { };

procMacro = myLib.buildPackage {
src = myLib.cleanCargoSource ./proc-macro;
};

simple = myLib.buildPackage {
src = myLib.cleanCargoSource ./simple;
};
Expand Down
7 changes: 7 additions & 0 deletions checks/nextest.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ let
partitionType = "hash";
cargoArtifacts = null;
};

nextestProcMacro = cargoNextest {
src = ./proc-macro;
pname = "nextest-proc-macro";
cargoArtifacts = null;
};
in
runCommand "nextestTests"
{
buildInputs = [
nextestSimple
nextestPartitionsCount
nextestPartitionsHash
nextestProcMacro
];
} ''
mkdir -p $out
Expand Down
7 changes: 7 additions & 0 deletions checks/proc-macro/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions checks/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "my-proc-macro"
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true
6 changes: 6 additions & 0 deletions checks/proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use proc_macro::TokenStream;

#[proc_macro_attribute]
pub fn identity(_attr: TokenStream, item: TokenStream) -> TokenStream {
item
}
7 changes: 7 additions & 0 deletions lib/cargoNextest.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{ cargo-nextest
, rustc
, lib
, stdenv
, mkCargoDerivation
, runCommand
}:
Expand Down Expand Up @@ -30,6 +32,11 @@ let
cargo nextest --version
'';

# Work around Nextest bug: https://github.com/nextest-rs/nextest/issues/267
preCheck = (args.preCheck or "") + lib.optionalString stdenv.isDarwin ''
export DYLD_FALLBACK_LIBRARY_PATH=$(${rustc}/bin/rustc --print sysroot)/lib
'';

checkPhaseCargoCommand = "cargo nextest ${cmd} $" + "{CARGO_PROFILE:+--cargo-profile $CARGO_PROFILE} ${cargoExtraArgs} ${cargoNextestExtraArgs} ${moreArgs}";

nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ cargo-nextest ];
Expand Down