about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/testers
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/testers')
-rw-r--r--nixpkgs/pkgs/build-support/testers/default.nix11
-rw-r--r--nixpkgs/pkgs/build-support/testers/hasPkgConfigModules/tester.nix (renamed from nixpkgs/pkgs/build-support/testers/hasPkgConfigModule/tester.nix)40
-rw-r--r--nixpkgs/pkgs/build-support/testers/hasPkgConfigModules/tests.nix (renamed from nixpkgs/pkgs/build-support/testers/hasPkgConfigModule/tests.nix)23
-rw-r--r--nixpkgs/pkgs/build-support/testers/test/default.nix2
4 files changed, 49 insertions, 27 deletions
diff --git a/nixpkgs/pkgs/build-support/testers/default.nix b/nixpkgs/pkgs/build-support/testers/default.nix
index d380dc6f30e1..3ff52ed0178c 100644
--- a/nixpkgs/pkgs/build-support/testers/default.nix
+++ b/nixpkgs/pkgs/build-support/testers/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, buildPackages, lib, callPackage, runCommand, stdenv, substituteAll, }:
+{ pkgs, buildPackages, lib, callPackage, runCommand, stdenv, substituteAll, testers }:
 # Documentation is in doc/builders/testers.chapter.md
 {
   # See https://nixos.org/manual/nixpkgs/unstable/#tester-testBuildFailure
@@ -137,7 +137,14 @@
         in
           nixosTesting.simpleTest calledTest;
 
-  hasPkgConfigModule = callPackage ./hasPkgConfigModule/tester.nix { };
+  hasPkgConfigModule =
+    { moduleName, ... }@args:
+    lib.warn "testers.hasPkgConfigModule has been deprecated in favor of testers.hasPkgConfigModules. It accepts a list of strings via the moduleNames argument instead of a single moduleName." (
+      testers.hasPkgConfigModules (builtins.removeAttrs args [ "moduleName" ] // {
+        moduleNames = [ moduleName ];
+      })
+    );
+  hasPkgConfigModules = callPackage ./hasPkgConfigModules/tester.nix { };
 
   testMetaPkgConfig = callPackage ./testMetaPkgConfig/tester.nix { };
 }
diff --git a/nixpkgs/pkgs/build-support/testers/hasPkgConfigModule/tester.nix b/nixpkgs/pkgs/build-support/testers/hasPkgConfigModules/tester.nix
index c8342cdd5c3b..755559038271 100644
--- a/nixpkgs/pkgs/build-support/testers/hasPkgConfigModule/tester.nix
+++ b/nixpkgs/pkgs/build-support/testers/hasPkgConfigModules/tester.nix
@@ -1,18 +1,18 @@
 # Static arguments
-{ runCommand, pkg-config }:
+{ lib, runCommand, pkg-config }:
 
 # Tester arguments
 { package,
-  moduleName,
-  testName ? "check-pkg-config-${moduleName}",
+  moduleNames ? package.meta.pkgConfigModules,
+  testName ? "check-pkg-config-${lib.concatStringsSep "-" moduleNames}",
 }:
 
 runCommand testName {
     nativeBuildInputs = [ pkg-config ];
     buildInputs = [ package ];
-    inherit moduleName;
+    inherit moduleNames;
     meta = {
-      description = "Test whether ${package.name} exposes pkg-config module ${moduleName}";
+      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.
@@ -30,18 +30,20 @@ runCommand testName {
         }
         package.meta;
   } ''
-    echo "checking pkg-config module $moduleName in $buildInputs"
-    set +e
-    version="$(pkg-config --modversion $moduleName)"
-    r=$?
-    set -e
-    if [[ $r = 0 ]]; then
-      echo "✅ pkg-config module $moduleName exists and has version $version"
-      echo "$version" > $out
-    else
-      echo "These modules were available in the input propagation closure:"
-      pkg-config --list-all
-      echo "❌ pkg-config module $moduleName was not found"
-      false
-    fi
+    for moduleName in $moduleNames; do
+      echo "checking pkg-config module $moduleName in $buildInputs"
+      set +e
+      version="$(pkg-config --modversion $moduleName)"
+      r=$?
+      set -e
+      if [[ $r = 0 ]]; then
+        echo "✅ pkg-config module $moduleName exists and has version $version"
+        printf '%s\t%s\n' "$moduleName" "$version" >> "$out"
+      else
+        echo "These modules were available in the input propagation closure:"
+        pkg-config --list-all
+        echo "❌ pkg-config module $moduleName was not found"
+        false
+      fi
+    done
   ''
diff --git a/nixpkgs/pkgs/build-support/testers/hasPkgConfigModule/tests.nix b/nixpkgs/pkgs/build-support/testers/hasPkgConfigModules/tests.nix
index 8005c3f93709..96569498fb15 100644
--- a/nixpkgs/pkgs/build-support/testers/hasPkgConfigModule/tests.nix
+++ b/nixpkgs/pkgs/build-support/testers/hasPkgConfigModules/tests.nix
@@ -1,19 +1,32 @@
 # cd nixpkgs
 # nix-build -A tests.testers.hasPkgConfigModule
-{ lib, testers, zlib, runCommand }:
+{ lib, testers, zlib, openssl, runCommand }:
 
 lib.recurseIntoAttrs {
 
-  zlib-has-zlib = testers.hasPkgConfigModule {
+  zlib-has-zlib = testers.hasPkgConfigModules {
     package = zlib;
-    moduleName = "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.hasPkgConfigModule {
+      testers.hasPkgConfigModules {
       package = zlib;
-      moduleName = "ylib";
+      moduleNames = [ "ylib" ];
       }
     );
   } ''
diff --git a/nixpkgs/pkgs/build-support/testers/test/default.nix b/nixpkgs/pkgs/build-support/testers/test/default.nix
index fc4df4964f39..c48c9f299ebf 100644
--- a/nixpkgs/pkgs/build-support/testers/test/default.nix
+++ b/nixpkgs/pkgs/build-support/testers/test/default.nix
@@ -12,7 +12,7 @@ let
 
 in
 lib.recurseIntoAttrs {
-  hasPkgConfigModule = pkgs.callPackage ../hasPkgConfigModule/tests.nix { };
+  hasPkgConfigModules = pkgs.callPackage ../hasPkgConfigModules/tests.nix { };
 
   runNixOSTest-example = pkgs-with-overlay.testers.runNixOSTest ({ lib, ... }: {
     name = "runNixOSTest-test";