summary refs log tree commit diff
path: root/pkgs/build-support/rust/default.nix
diff options
context:
space:
mode:
authorDaniël de Kok <me@danieldk.eu>2021-02-15 10:26:40 +0100
committerDaniël de Kok <me@danieldk.eu>2021-02-16 08:09:15 +0100
commit05e40e79a8559cdbe323ab05e003d56033000ee8 (patch)
treec4a1ff0bca75bc2689c33a04708678b6a551cdb2 /pkgs/build-support/rust/default.nix
parent9757c7101a0527c001fa9e9832764d5dc106ff25 (diff)
downloadnixpkgs-05e40e79a8559cdbe323ab05e003d56033000ee8.tar
nixpkgs-05e40e79a8559cdbe323ab05e003d56033000ee8.tar.gz
nixpkgs-05e40e79a8559cdbe323ab05e003d56033000ee8.tar.bz2
nixpkgs-05e40e79a8559cdbe323ab05e003d56033000ee8.tar.lz
nixpkgs-05e40e79a8559cdbe323ab05e003d56033000ee8.tar.xz
nixpkgs-05e40e79a8559cdbe323ab05e003d56033000ee8.tar.zst
nixpkgs-05e40e79a8559cdbe323ab05e003d56033000ee8.zip
buildRustPackage: factor out check phase to cargoCheckHook
API change:

`cargoParallelTestThreads` suggests that this attribute sets the
number of threads used during tests, while it is actually a boolean
option (use 1 thread or NIX_BUILD_CORES threads). In the hook, this
is replaced by a more canonical name `dontUseCargoParallelTests`.
Diffstat (limited to 'pkgs/build-support/rust/default.nix')
-rw-r--r--pkgs/build-support/rust/default.nix26
1 files changed, 10 insertions, 16 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
index b7d6cb522bc..760f7c920da 100644
--- a/pkgs/build-support/rust/default.nix
+++ b/pkgs/build-support/rust/default.nix
@@ -2,8 +2,8 @@
 , lib
 , buildPackages
 , cacert
-, cargo
 , cargoBuildHook
+, cargoCheckHook
 , cargoInstallHook
 , cargoSetupHook
 , fetchCargoTarball
@@ -42,7 +42,6 @@
 , cargoVendorDir ? null
 , checkType ? buildType
 , depsExtraArgs ? {}
-, cargoParallelTestThreads ? true
 
 # Toggles whether a custom sysroot is created when the target is a .json file.
 , __internal_dontAddSysroot ? false
@@ -105,8 +104,15 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // lib.optionalAttrs u
 
   patchRegistryDeps = ./patch-registry-deps;
 
-  nativeBuildInputs = nativeBuildInputs ++
-    [ cacert git cargo cargoBuildHook cargoInstallHook cargoSetupHook rustc ];
+  nativeBuildInputs = nativeBuildInputs ++ [
+    cacert
+    git
+    cargoBuildHook
+    cargoCheckHook
+    cargoInstallHook
+    cargoSetupHook
+    rustc
+  ];
 
   buildInputs = buildInputs ++ lib.optional stdenv.hostPlatform.isMinGW windows.pthreads;
 
@@ -126,18 +132,6 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // lib.optionalAttrs u
     runHook postConfigure
   '';
 
-  checkPhase = args.checkPhase or (let
-    argstr = "${lib.optionalString (checkType == "release") "--release"} --target ${target} --frozen";
-    threads = if cargoParallelTestThreads then "$NIX_BUILD_CORES" else "1";
-  in ''
-    ${lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"}
-    runHook preCheck
-    echo "Running cargo test ${argstr} -- ''${checkFlags} ''${checkFlagsArray+''${checkFlagsArray[@]}}"
-    cargo test -j $NIX_BUILD_CORES ${argstr} -- --test-threads=${threads} ''${checkFlags} ''${checkFlagsArray+"''${checkFlagsArray[@]}"}
-    runHook postCheck
-    ${lib.optionalString (buildAndTestSubdir != null) "popd"}
-  '');
-
   doCheck = args.doCheck or true;
 
   strictDeps = true;