testers.hasCmakeConfigModules: add self tests

This commit is contained in:
qbisi 2025-05-30 17:58:58 +08:00
parent 11291afcb3
commit e4ab873cc1
2 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,73 @@
# cd nixpkgs
# nix-build -A tests.testers.hasCmakeConfigModules
{
lib,
testers,
boost,
mpi,
eigen,
runCommand,
}:
lib.recurseIntoAttrs {
boost-versions-match = testers.hasCmakeConfigModules {
package = boost;
moduleNames = [
"Boost"
"boost_math"
];
versionCheck = true;
};
boost-versions-mismatch = testers.testBuildFailure (
testers.hasCmakeConfigModules {
package = boost;
moduleNames = [
"Boost"
"boost_math"
];
version = "1.2.3"; # Deliberately-incorrect version number
versionCheck = true;
}
);
boost-no-versionCheck = testers.hasCmakeConfigModules {
package = boost;
moduleNames = [
"Boost"
"boost_math"
];
version = "1.2.3"; # Deliberately-incorrect version number
versionCheck = false;
};
boost-has-boost_mpi = testers.hasCmakeConfigModules {
package = boost.override { useMpi = true; };
moduleNames = [
"boost_mpi"
];
buildInputs = [ mpi ];
};
boost_mpi-does-not-have-mpi = testers.testBuildFailure (
testers.hasCmakeConfigModules {
package = boost.override { useMpi = true; };
moduleNames = [
"boost_mpi"
];
}
);
eigen-has-Eigen = testers.hasCmakeConfigModules {
package = eigen;
moduleNames = [ "Eigen3" ];
};
eigen-does-not-have-eigen = testers.testBuildFailure (
testers.hasCmakeConfigModules {
package = eigen;
moduleNames = [ "eigen3" ];
}
);
}

View file

@ -37,6 +37,8 @@ lib.recurseIntoAttrs {
hasPkgConfigModules = pkgs.callPackage ../hasPkgConfigModules/tests.nix { }; hasPkgConfigModules = pkgs.callPackage ../hasPkgConfigModules/tests.nix { };
hasCmakeConfigModules = pkgs.callPackage ../hasCmakeConfigModules/tests.nix { };
shellcheck = pkgs.callPackage ../shellcheck/tests.nix { }; shellcheck = pkgs.callPackage ../shellcheck/tests.nix { };
shfmt = pkgs.callPackages ../shfmt/tests.nix { }; shfmt = pkgs.callPackages ../shfmt/tests.nix { };