Skip to content

Commit

Permalink
tests.splicing: add
Browse files Browse the repository at this point in the history
  • Loading branch information
Artturin committed Dec 17, 2022
1 parent 519ffa6 commit 20c596c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkgs/test/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ with pkgs;

cross = callPackage ./cross {};

splicing = callPackage ./splicing {};

php = recurseIntoAttrs (callPackages ./php {});

rustCustomSysroot = callPackage ./rust-sysroot {};
Expand Down
40 changes: 40 additions & 0 deletions pkgs/test/splicing/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{ pkgs, stdenvNoCC, lib, }:
let
pkgsCross = pkgs.pkgsCross.aarch64-multiplatform.__splicedPackages;
tests =
let
pythonInNativeBuildInputs = lib.elemAt pkgsCross.python3Packages.xpybutil.nativeBuildInputs 0;
overridenAttr = pkgsCross.hello.overrideAttrs (_: { something = "hello"; });
in
[
({
name = "pythonInNativeBuildInputsShouldBeNative";
expr = pythonInNativeBuildInputs.stdenv.hostPlatform.system == "x86_64-linux";
expected = true;
})
({
name = "overridenAttrShouldHaveSplicedAndSomething";
expr = if overridenAttr ? __spliced then overridenAttr.something == overridenAttr.__spliced.buildHost.something else false;
expected = true;
})
({
name = "splicedShouldBeOverriden";
expr = pkgsCross.nix.aws-sdk-cpp.cmakeFlags == pkgsCross.nix.aws-sdk-cpp.__spliced.hostTarget.cmakeFlags;
expected = true;
})
({
name = "notCrossOverriden";
expr = (pkgs.hello.overrideAttrs (_: _: { passthru = { o = "works"; }; })) ? o;
expected = true;
})
];
in
{
test-splicing = stdenvNoCC.mkDerivation {
name = "test-splicing";
passthru = { inherit tests; };
buildCommand = ''
touch $out
'' + lib.concatMapStringsSep "\n" (t: "([[ ${lib.boolToString t.expr} == ${lib.boolToString t.expected} ]] && echo '${t.name} success') || (echo '${t.name} fail' && exit 1)") tests;
};
}

0 comments on commit 20c596c

Please sign in to comment.