From 5d2a20c93aeb45dd6de3cbc522692499ff161c34 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 29 Nov 2020 16:23:00 +0000 Subject: [PATCH 1/2] buildRustCrateTests: Move to tests.buildRustCrate I think it is preferable to separate the tests from the "real" packages. --- pkgs/test/default.nix | 1 + pkgs/top-level/all-packages.nix | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 8746f065b1b..f45e981cff0 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -39,6 +39,7 @@ with pkgs; cross = callPackage ./cross {}; rustCustomSysroot = callPackage ./rust-sysroot {}; + buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { }; nixos-functions = callPackage ./nixos-functions {}; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3937ae566e6..5c464236602 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10071,7 +10071,6 @@ in buildRustCrate = callPackage ../build-support/rust/build-rust-crate { }; buildRustCrateHelpers = callPackage ../build-support/rust/build-rust-crate/helpers.nix { }; - buildRustCrateTests = recurseIntoAttrs (callPackage ../build-support/rust/build-rust-crate/test { }); cratesIO = callPackage ../build-support/rust/crates-io.nix { }; cargo-web = callPackage ../development/tools/cargo-web { From ddeef0d3221ea182b5411c9084b59373883d0edb Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 29 Nov 2020 16:28:12 +0000 Subject: [PATCH 2/2] tests.buildRustCrate: Fix after hashing method change As @lopsided98 points out in #105305, since the hashes are now target sensative, and until we find reason to actually care to test what they are exactly, we are best just normalizing them away in the tests. --- .../rust/build-rust-crate/test/default.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/build-support/rust/build-rust-crate/test/default.nix b/pkgs/build-support/rust/build-rust-crate/test/default.nix index f6cd54c4ee3..65c8880b134 100644 --- a/pkgs/build-support/rust/build-rust-crate/test/default.nix +++ b/pkgs/build-support/rust/build-rust-crate/test/default.nix @@ -146,12 +146,18 @@ let }; in runCommand "assert-outputs-${name}" { - } '' + } ('' local actualFiles=$(mktemp) cd "${crateOutput}" - find . -type f | sort >$actualFiles - diff -q ${expectedFilesFile} $actualFiles >/dev/null || { + find . -type f \ + | sort \ + '' + # sed out the hash because it differs per platform + + '' + | sed -E -e 's/-[0-9a-fA-F]{10}\.rlib/-HASH.rlib/g' \ + > "$actualFiles" + diff -q ${expectedFilesFile} "$actualFiles" > /dev/null || { echo -e "\033[0;1;31mERROR: Difference in expected output files in ${crateOutput} \033[0m" >&2 echo === Got: sed -e 's/^/ /' $actualFiles @@ -164,7 +170,7 @@ let exit 1 } touch $out - '' + '') ; in rec { @@ -594,7 +600,7 @@ let }; expectedFiles = [ "./nix-support/propagated-build-inputs" - "./lib/libtest_lib-042a1fdbef.rlib" + "./lib/libtest_lib-HASH.rlib" "./lib/link" ]; }; @@ -611,7 +617,7 @@ let }; expectedFiles = [ "./nix-support/propagated-build-inputs" - "./lib/libtest_lib-042a1fdbef.rlib" + "./lib/libtest_lib-HASH.rlib" "./lib/link" ]; };