diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-01-23 19:08:46 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-01-29 09:51:54 +0100 |
commit | e93cfb250b683f3ffd9adc957c14b5b3b2e108ae (patch) | |
tree | 89c7189d24506c225283980417cc86c72ed785d9 /pkgs | |
parent | 7790eafbdcbc85a8e48912189400565dd039cb64 (diff) |
tests.pkg-configPackages: Filter out unsupported packages
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/test/default.nix | 17 | ||||
-rw-r--r-- | pkgs/test/pkg-config-packages.nix | 24 |
2 files changed, 39 insertions, 2 deletions
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 8ff0e163395f..82134b051d4e 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -51,7 +51,22 @@ with pkgs; php = recurseIntoAttrs (callPackages ./php {}); - pkg-configPackages = callPackage ./pkg-config-packages.nix { }; + pkg-configPackages = + let + # pkg-configPackages 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 { }; 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 index d61902cf1f46..8e4e5253f9b1 100644 --- a/pkgs/test/pkg-config-packages.nix +++ b/pkgs/test/pkg-config-packages.nix @@ -1,6 +1,8 @@ { lib, pkg-config, pkg-configPackages, runCommand }: let - allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTest k v) pkg-configPackages; + inherit (lib.strings) escapeNixIdentifier; + + allTests = lib.mapAttrs (k: v: if v == null then null else makePkgConfigTestMaybe k v) pkg-configPackages; # nix-build rejects attribute names with periods # This will build those regardless. @@ -10,6 +12,26 @@ let 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 makePkgConfigTest moduleName pkg; + makePkgConfigTest = moduleName: pkg: runCommand "check-pkg-config-${moduleName}" { nativeBuildInputs = [ pkg-config ]; buildInputs = [ pkg ]; |