1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-08 19:46:06 +01:00

tests/generated: add a separate error for unsupported entries

Only used for LSP packages, where we have a separate list of unsupported
LSP servers in generated/unsupported-lspconfig-servers.json
This commit is contained in:
Matt Sturgeon 2025-10-02 22:40:02 +01:00
parent 5c6ee4186f
commit 308e5b3843

View file

@ -21,6 +21,8 @@ let
declared, declared,
# A list of names generated by generate-files # A list of names generated by generate-files
generated, generated,
# A list of names that are explicitly unsupported upstream
unsupported ? [ ],
# The filename where names are declared (used in error messages) # The filename where names are declared (used in error messages)
declarationFile, declarationFile,
}: }:
@ -29,11 +31,14 @@ let
loc: lib.optional (!lib.hasAttrByPath loc pkgs) (lib.concatStringsSep "." loc) loc: lib.optional (!lib.hasAttrByPath loc pkgs) (lib.concatStringsSep "." loc)
) (builtins.map lib.toList packages); ) (builtins.map lib.toList packages);
undeclared = lib.filter (name: !(lib.elem name declared)) generated; undeclared = lib.filter (name: !(lib.elem name declared)) generated;
uselesslyDeclared = lib.filter (name: !(lib.elem name generated)) declared; uselesslyDeclared = lib.partition (name: lib.elem name unsupported) (
lib.filter (name: !(lib.elem name generated)) declared
);
in in
describeErrors "${name}: The following are not found in `pkgs`, but are declared in ${declarationFile}:" missingFromPkgs describeErrors "${name}: The following are not found in `pkgs`, but are declared in ${declarationFile}:" missingFromPkgs
++ describeErrors "${name}: The following are not declared in ${declarationFile}:" undeclared ++ describeErrors "${name}: The following are not declared in ${declarationFile}:" undeclared
++ describeErrors "${name}: The following are not listed upstream, but are declared in ${declarationFile}:" uselesslyDeclared; ++ describeErrors "${name}: The following are now unsupported upstream, but are declared in ${declarationFile}:" uselesslyDeclared.right
++ describeErrors "${name}: The following are not listed upstream, but are declared in ${declarationFile}:" uselesslyDeclared.wrong;
# The error message provided to the derivation. # The error message provided to the derivation.
# The test fails if this is non-empty. # The test fails if this is non-empty.
@ -50,11 +55,8 @@ let
declared = unpackaged ++ lib.attrsets.attrNames (packages // customCmd); declared = unpackaged ++ lib.attrsets.attrNames (packages // customCmd);
generated = lib.pipe ../generated/lspconfig-servers.json [ generated = builtins.attrNames (lib.importJSON ../generated/lspconfig-servers.json);
lib.importJSON unsupported = lib.importJSON ../generated/unsupported-lspconfig-servers.json;
(builtins.map (lib.getAttr "name"))
lib.lists.unique
];
} }
) )
++ checkDeclarations ( ++ checkDeclarations (