nix-community.nixvim/tests/default.nix
Matt Sturgeon 975af6a498
tests: simplify fetch-tests slightly
Simplify by reducing the number of transformations done to the
test-files' test-case modules attr.

Since `pkgs.linkFarm` can accept _either_ a list or an attrset, we don't
need to transform the attrset into a list.
2024-08-28 05:45:01 +01:00

57 lines
1.4 KiB
Nix

{
lib ? pkgs.lib,
helpers,
pkgs,
pkgsUnfree,
}:
let
fetchTests = import ./fetch-tests.nix;
test-derivation = import ../lib/tests.nix { inherit pkgs lib; };
inherit (test-derivation) mkTestDerivationFromNixvimModule;
moduleToTest =
name: module:
mkTestDerivationFromNixvimModule {
inherit name module;
pkgs = pkgsUnfree;
};
# List of files containing configurations
testFiles = fetchTests {
inherit lib pkgs helpers;
root = ./test-sources;
};
exampleFiles = {
name = "examples";
file = ../example.nix;
cases =
let
config = import ../example.nix { inherit pkgs; };
in
{
main = builtins.removeAttrs config.programs.nixvim [
# This is not available to standalone modules, only HM & NixOS Modules
"enable"
# This is purely an example, it does not reflect a real usage
"extraConfigLua"
"extraConfigVim"
];
};
};
in
# We attempt to build & execute all configurations
lib.pipe (testFiles ++ [ exampleFiles ]) [
(builtins.map (file: {
inherit (file) name;
path = pkgs.linkFarm file.name (builtins.mapAttrs moduleToTest file.cases);
}))
(helpers.groupListBySize 10)
(lib.imap1 (
i: group: rec {
name = "test-${toString i}";
value = pkgs.linkFarm name group;
}
))
builtins.listToAttrs
]