push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
# Static arguments
{
lib,
runCommand,
pkg-config,
}:
# Tester arguments
{
package,
moduleNames ? package.meta.pkgConfigModules,
testName ? "check-pkg-config-${package.pname or package.name}",
version ? package.version or null,
versionCheck ? false,
}:
runCommand testName
{
nativeBuildInputs = [ pkg-config ];
buildInputs = [ package ];
inherit moduleNames version versionCheck;
meta = {
description = "Test whether ${package.name} exposes pkg-config modules ${lib.concatStringsSep ", " moduleNames}";
}
# Make sure licensing info etc is preserved, as this is a concern for e.g. cache.nixos.org,
# as hydra can't check this meta info in dependencies.
# The test itself is just Nixpkgs, with MIT license.
// builtins.intersectAttrs {
available = throw "unused";
broken = throw "unused";
insecure = throw "unused";
license = throw "unused";
maintainers = throw "unused";
teams = throw "unused";
platforms = throw "unused";
unfree = throw "unused";
unsupported = throw "unused";
} package.meta;
}
''
touch "$out"
notFound=0
versionMismatch=0
for moduleName in $moduleNames; do
echo "checking pkg-config module $moduleName in $buildInputs"
set +e
moduleVersion="$($PKG_CONFIG --modversion $moduleName)"
r=$?
set -e
if [[ $r = 0 ]]; then
if [[ "$moduleVersion" == "$version" ]]; then
echo " pkg-config module $moduleName exists and has version $moduleVersion"
else
echo "${
if versionCheck then "" else ""
} pkg-config module $moduleName exists at version $moduleVersion != $version (drv version)"
((versionMismatch+=1))
fi
printf '%s\t%s\n' "$moduleName" "$version" >> "$out"
else
echo " pkg-config module $moduleName was not found"
((notFound+=1))
fi
done
if [[ $notFound -eq 0 ]] && ([[ $versionMismatch -eq 0 ]] || [[ -z "$versionCheck" ]]); then
exit 0
fi
if [[ $notFound -ne 0 ]]; then
echo "$notFound modules not found"
echo "These modules were available in the input propagation closure:"
$PKG_CONFIG --list-all
fi
if [[ $versionMismatch -ne 0 ]]; then
echo "$versionMismatch version mismatches"
fi
exit 1
''

View File

@@ -0,0 +1,77 @@
# cd nixpkgs
# nix-build -A tests.testers.hasPkgConfigModules
{
lib,
testers,
miniz,
zlib,
openssl,
runCommand,
}:
lib.recurseIntoAttrs {
miniz-versions-match = testers.hasPkgConfigModules {
package = miniz;
versionCheck = true;
};
miniz-versions-mismatch = testers.testBuildFailure (
testers.hasPkgConfigModules {
package = miniz;
version = "1.2.3"; # Deliberately-incorrect version number
versionCheck = true;
}
);
miniz-no-versionCheck = testers.hasPkgConfigModules {
package = miniz;
version = "1.2.3"; # Deliberately-incorrect version number
};
zlib-has-zlib = testers.hasPkgConfigModules {
package = zlib;
moduleNames = [ "zlib" ];
};
zlib-has-meta-pkgConfigModules = testers.hasPkgConfigModules {
package = zlib;
};
openssl-has-openssl = testers.hasPkgConfigModules {
package = openssl;
moduleNames = [ "openssl" ];
};
openssl-has-all-meta-pkgConfigModules = testers.hasPkgConfigModules {
package = openssl;
};
zlib-does-not-have-ylib =
runCommand "zlib-does-not-have-ylib"
{
failed = testers.testBuildFailure (
testers.hasPkgConfigModules {
package = zlib;
moduleNames = [ "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
'';
}