From 1d4d9facbcb00d2bce2fe15d9c8fdaa2137833eb Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 12 May 2024 13:47:20 +0000 Subject: [PATCH 1/4] tests.testers.hasPkgConfigModules: test the `versionCheck` parameter Shell script is currently buggy and effectively ignores the value, always enforcing version match: https://github.com/NixOS/nixpkgs/pull/307770#issuecomment-2102586718 --- pkgs/build-support/testers/hasPkgConfigModules/tests.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/testers/hasPkgConfigModules/tests.nix b/pkgs/build-support/testers/hasPkgConfigModules/tests.nix index bf992d040b4b..adad93507984 100644 --- a/pkgs/build-support/testers/hasPkgConfigModules/tests.nix +++ b/pkgs/build-support/testers/hasPkgConfigModules/tests.nix @@ -11,10 +11,15 @@ lib.recurseIntoAttrs { miniz-versions-mismatch = testers.testBuildFailure (testers.hasPkgConfigModules { package = miniz; - version = "1.2.3"; + 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" ]; From 4af3b807fccfddfceb4aad422018a5f9e8cdb8a0 Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 12 May 2024 13:48:23 +0000 Subject: [PATCH 2/4] testers.hasPkgConfigModules: fix `versionCheck` conditional Broke tests, as the version check was effectively always enabled: https://github.com/NixOS/nixpkgs/pull/307770#issuecomment-2102586718 --- pkgs/build-support/testers/hasPkgConfigModules/tester.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix index b8ae884ba7b0..6a09255bde6c 100644 --- a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix +++ b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix @@ -55,7 +55,7 @@ runCommand testName { fi done - if [[ $notFound -eq 0 ]] && ([[ $versionMismatch -eq 0 ]] || [[ "$versionCheck" == false ]]); then + if [[ $notFound -eq 0 ]] && ([[ $versionMismatch -eq 0 ]] || [[ -z "$versionCheck" ]]); then exit 0 fi if [[ $notFound -ne 0 ]]; then From 43efaaaae80c77e81145067c0b2b57109dd0b33d Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 12 May 2024 14:10:54 +0000 Subject: [PATCH 3/4] =?UTF-8?q?testers.hasPkgConfigModules:=20don't=20disp?= =?UTF-8?q?lay=20=E2=9D=8C=20on=20ignored=20version=20mismatches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/build-support/testers/hasPkgConfigModules/tester.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix index 6a09255bde6c..7b22ffbf6f19 100644 --- a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix +++ b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix @@ -45,7 +45,7 @@ runCommand testName { 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" + echo "${if versionCheck then "❌" else "⚠"} pkg-config module $moduleName exists and has version $moduleVersion when $version was expected" ((versionMismatch+=1)) fi printf '%s\t%s\n' "$moduleName" "$version" >> "$out" From bf4d46e338590ffb19bae620e7a7eff64b0baf89 Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 12 May 2024 20:48:09 +0000 Subject: [PATCH 4/4] =?UTF-8?q?fixup!=20testers.hasPkgConfigModules:=20don?= =?UTF-8?q?'t=20display=20=E2=9D=8C=20on=20ignored=20version=20mismatches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/build-support/testers/hasPkgConfigModules/tester.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix index 7b22ffbf6f19..e9f246deaaf2 100644 --- a/pkgs/build-support/testers/hasPkgConfigModules/tester.nix +++ b/pkgs/build-support/testers/hasPkgConfigModules/tester.nix @@ -45,7 +45,7 @@ runCommand testName { 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 and has version $moduleVersion when $version was expected" + 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"