about summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-01-29 08:54:13 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-01-29 09:51:55 +0100
commit3be7ea8c891b3209e92e961fe689649fb0333bcc (patch)
tree491de62a6676ccb943f8900628598990ea5f9bd2 /pkgs/test
parent811bf8ade022b34148a5b71242ca1a713865c7fa (diff)
top-level/pkg-config: Make tests easy to find
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/default.nix17
-rw-r--r--pkgs/test/pkg-config-packages.nix81
2 files changed, 1 insertions, 97 deletions
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index 72b22f7f68658..39039c5950e46 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -51,22 +51,7 @@ with pkgs;
 
   php = recurseIntoAttrs (callPackages ./php {});
 
-  defaultPkgConfigPackages =
-    let
-      # defaultPkgConfigPackages test needs a Nixpkgs with allowUnsupportedPlatform
-      # in order to filter out the unsupported packages without throwing any errors
-      # tryEval would be too fragile, masking different problems as if they're
-      # unsupported platform problems.
-      allPkgs = import ../top-level {
-        system = pkgs.stdenv.hostPlatform.system;
-        localSystem = pkgs.stdenv.hostPlatform.system;
-        config = {
-          allowUnsupportedSystem = true;
-        };
-        overlays = [];
-      };
-    in
-    allPkgs.callPackage ./pkg-config-packages.nix { };
+  pkg-config = recurseIntoAttrs (callPackage ../top-level/pkg-config/tests.nix { });
 
   rustCustomSysroot = callPackage ./rust-sysroot {};
   buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { };
diff --git a/pkgs/test/pkg-config-packages.nix b/pkgs/test/pkg-config-packages.nix
deleted file mode 100644
index 8cb6cc57753f2..0000000000000
--- a/pkgs/test/pkg-config-packages.nix
+++ /dev/null
@@ -1,81 +0,0 @@
-{ lib, pkg-config, defaultPkgConfigPackages, runCommand }:
-let
-  inherit (lib.strings) escapeNixIdentifier;
-
-  allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) defaultPkgConfigPackages;
-
-  # nix-build rejects attribute names with periods
-  # This will build those regardless.
-  tests-combined = runCommand "pkg-config-checks" {
-    allTests = lib.attrValues allTests;
-  } ''
-    touch $out
-  '';
-
-  makePkgConfigTestMaybe = moduleName: pkg:
-    if ! lib.isDerivation pkg
-    then
-      throw "pkg-config module `${escapeNixIdentifier moduleName}` is not defined to be a derivation. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs."
-
-    else if ! pkg?meta.unsupported
-    then
-      throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.unsupported` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config-packages.nix` in Nixpkgs."
-
-    else if pkg.meta.unsupported
-    then
-      # We return `null` instead of doing a `filterAttrs`, because with
-      # `filterAttrs` the evaluator would not be able to return the attribute
-      # set without first evaluating all of the attribute _values_. This would
-      # be rather expensive, and severly slow down the use case of getting a
-      # single test, which we want to do in `passthru.tests`, or interactively.
-      null
-
-    else if ! pkg?meta.broken
-    then
-      throw "pkg-config module `${escapeNixIdentifier moduleName}` does not have a `meta.broken` attribute. This can't be right. Please check the attribute value for `${escapeNixIdentifier moduleName}` in `pkgs/top-level/pkg-config.packages.nix` in Nixpkgs."
-
-    else if pkg.meta.broken
-    then null
-
-    else makePkgConfigTest moduleName pkg;
-
-  makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" {
-    nativeBuildInputs = [ pkg-config ];
-    buildInputs = [ pkg ];
-    inherit moduleName;
-    meta = {
-      description = "Test whether ${pkg.name} exposes pkg-config module ${moduleName}";
-    }
-    # 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";
-          platforms = throw "unused";
-          unfree = throw "unused";
-          unsupported = throw "unused";
-        }
-        pkg.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
-  '';
-in
-  allTests // { inherit tests-combined; }