depot/third_party/nixpkgs/pkgs/build-support/testers/hasPkgConfigModule/tests.nix
Default email a0cb138ada Project import generated by Copybara.
GitOrigin-RevId: a100acd7bbf105915b0004427802286c37738fef
2023-02-02 18:25:31 +00:00

36 lines
915 B
Nix

# cd nixpkgs
# nix-build -A tests.testers.hasPkgConfigModule
{ lib, testers, zlib, runCommand }:
lib.recurseIntoAttrs {
zlib-has-zlib = testers.hasPkgConfigModule {
package = zlib;
moduleName = "zlib";
};
zlib-does-not-have-ylib = runCommand "zlib-does-not-have-ylib" {
failed = testers.testBuildFailure (
testers.hasPkgConfigModule {
package = zlib;
moduleName = "ylib";
}
);
} ''
echo 'it logs a relevant error message'
{
grep -F "pkg-config module ylib was not found" $failed/testBuildFailure.log
}
echo 'it logs which pkg-config modules are available, to be helpful'
{
# grep -v: the string zlib does also occur in a store path in an earlier message, which isn't particularly helpful
grep -v "checking pkg-config module" < $failed/testBuildFailure.log \
| grep -F "zlib"
}
# done
touch $out
'';
}