mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
tests.nixpkgs-check-by-name: Sort the eval validation results
Not that important, but nice. Also adds a nice test case show-casing the two current ratchet checks at once.
This commit is contained in:
parent
57afdc545b
commit
cbff02834f
@ -79,34 +79,37 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
byNameAttrs = map (name: [
|
||||
name
|
||||
{
|
||||
ByName =
|
||||
if ! pkgs ? ${name} then
|
||||
{ Missing = null; }
|
||||
else
|
||||
{ Existing = attrInfo name pkgs.${name}; };
|
||||
}
|
||||
]) attrs;
|
||||
byNameAttrs = builtins.listToAttrs (map (name: {
|
||||
inherit name;
|
||||
value.ByName =
|
||||
if ! pkgs ? ${name} then
|
||||
{ Missing = null; }
|
||||
else
|
||||
{ Existing = attrInfo name pkgs.${name}; };
|
||||
}) attrs);
|
||||
|
||||
# Information on all attributes that exist but are not in pkgs/by-name.
|
||||
# We need this to enforce pkgs/by-name for new packages
|
||||
nonByNameAttrs = map (name:
|
||||
nonByNameAttrs = builtins.mapAttrs (name: value:
|
||||
let
|
||||
output = attrInfo name pkgs.${name};
|
||||
output = attrInfo name value;
|
||||
result = builtins.tryEval (builtins.deepSeq output null);
|
||||
in
|
||||
[
|
||||
name
|
||||
{
|
||||
NonByName =
|
||||
if result.success then
|
||||
{ EvalSuccess = output; }
|
||||
else
|
||||
{ EvalFailure = null; };
|
||||
}
|
||||
]
|
||||
) (builtins.attrNames (builtins.removeAttrs pkgs attrs));
|
||||
{
|
||||
NonByName =
|
||||
if result.success then
|
||||
{ EvalSuccess = output; }
|
||||
else
|
||||
{ EvalFailure = null; };
|
||||
}
|
||||
) (builtins.removeAttrs pkgs attrs);
|
||||
|
||||
# All attributes
|
||||
attributes = byNameAttrs // nonByNameAttrs;
|
||||
in
|
||||
byNameAttrs ++ nonByNameAttrs
|
||||
# We output them in the form [ [ <name> <value> ] ]` such that the Rust side
|
||||
# doesn't need to sort them again to get deterministic behavior (good for testing)
|
||||
map (name: [
|
||||
name
|
||||
attributes.${name}
|
||||
]) (builtins.attrNames attributes)
|
||||
|
@ -0,0 +1,6 @@
|
||||
self: super: {
|
||||
a = self.callPackage ./pkgs/by-name/a/a/package.nix { };
|
||||
b = self.callPackage ({ someDrv }: someDrv) { };
|
||||
c = self.callPackage ./pkgs/by-name/c/c/package.nix { };
|
||||
d = self.callPackage ({ someDrv }: someDrv) { };
|
||||
}
|
@ -0,0 +1 @@
|
||||
import ../mock-nixpkgs.nix { root = ./.; }
|
@ -0,0 +1,4 @@
|
||||
pkgs.a: This attribute is manually defined (most likely in pkgs/top-level/all-packages.nix), which is only allowed if the definition is of the form `pkgs.callPackage pkgs/by-name/a/a/package.nix { ... }` with a non-empty second argument.
|
||||
pkgs.b: This is a new top-level package of the form `callPackage ... { }`. Please define it in pkgs/by-name/b/b/package.nix instead. See `pkgs/by-name/README.md` for more details. Since the second `callPackage` argument is `{ }`, no manual `callPackage` (e.g. in `pkgs/top-level/all-packages.nix`) is needed anymore.
|
||||
pkgs.c: This attribute is manually defined (most likely in pkgs/top-level/all-packages.nix), which is only allowed if the definition is of the form `pkgs.callPackage pkgs/by-name/c/c/package.nix { ... }` with a non-empty second argument.
|
||||
pkgs.d: This is a new top-level package of the form `callPackage ... { }`. Please define it in pkgs/by-name/d/d/package.nix instead. See `pkgs/by-name/README.md` for more details. Since the second `callPackage` argument is `{ }`, no manual `callPackage` (e.g. in `pkgs/top-level/all-packages.nix`) is needed anymore.
|
@ -0,0 +1 @@
|
||||
{ someDrv }: someDrv
|
@ -0,0 +1 @@
|
||||
{ someDrv }: someDrv
|
Loading…
Reference in New Issue
Block a user