mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-22 04:45:39 +00:00
testers.hasPkgConfigModules: Optionally check each module's version
This commit is contained in:
parent
5fce6cb334
commit
1e9d263dd7
@ -5,12 +5,14 @@
|
||||
{ package,
|
||||
moduleNames ? package.meta.pkgConfigModules,
|
||||
testName ? "check-pkg-config-${lib.concatStringsSep "-" moduleNames}",
|
||||
version ? package.version or null,
|
||||
versionCheck ? false,
|
||||
}:
|
||||
|
||||
runCommand testName {
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [ package ];
|
||||
inherit moduleNames;
|
||||
inherit moduleNames version versionCheck;
|
||||
meta = {
|
||||
description = "Test whether ${package.name} exposes pkg-config modules ${lib.concatStringsSep ", " moduleNames}.";
|
||||
}
|
||||
@ -32,14 +34,20 @@ runCommand testName {
|
||||
} ''
|
||||
touch "$out"
|
||||
notFound=0
|
||||
versionMismatch=0
|
||||
for moduleName in $moduleNames; do
|
||||
echo "checking pkg-config module $moduleName in $buildInputs"
|
||||
set +e
|
||||
version="$($PKG_CONFIG --modversion $moduleName)"
|
||||
moduleVersion="$($PKG_CONFIG --modversion $moduleName)"
|
||||
r=$?
|
||||
set -e
|
||||
if [[ $r = 0 ]]; then
|
||||
echo "✅ pkg-config module $moduleName exists and has version $version"
|
||||
if [[ "$moduleVersion" == "$version" ]]; then
|
||||
echo "✅ pkg-config module $moduleName exists and has version $moduleVersion"
|
||||
else
|
||||
echo "❌ pkg-config module $moduleName exists and has version $moduleVersion when $version was expected"
|
||||
((versionMismatch+=1))
|
||||
fi
|
||||
printf '%s\t%s\n' "$moduleName" "$version" >> "$out"
|
||||
else
|
||||
echo "❌ pkg-config module $moduleName was not found"
|
||||
@ -47,10 +55,16 @@ runCommand testName {
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $notFound -eq 0 ]] && ([[ $versionMismatch -eq 0 ]] || [[ "$versionCheck" == false ]]); 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
|
||||
exit 1
|
||||
fi
|
||||
if [[ $versionMismatch -ne 0 ]]; then
|
||||
echo "$versionMismatch version mismatches"
|
||||
fi
|
||||
exit 1
|
||||
''
|
||||
|
Loading…
Reference in New Issue
Block a user