diff options
author | nicoo <nicoo@mur.at> | 2024-04-29 16:33:54 +0000 |
---|---|---|
committer | nicoo <nicoo@mur.at> | 2024-04-30 20:34:07 +0000 |
commit | 1e9d263dd71d0b42baa8b0d6699864af9fbb669f (patch) | |
tree | 1bb83074efa092d4eaf541c86efe117fa43852c1 /pkgs/build-support | |
parent | 5fce6cb3342b834018d774355ac64464a0a821c8 (diff) |
testers.hasPkgConfigModules: Optionally check each module's version
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/testers/hasPkgConfigModules/tester.nix | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix index e2fc8c5bc2e0f..b8ae884ba7b0f 100644 --- a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix +++ b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix @@ -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 '' |