nix-community.nixvim/tests/default.nix
Matt Sturgeon 123a55ed6f
tests: remove special treatment of module
Since we no longer need to extract `tests.dontRun` from an attrset, we
no longer need the "special" `module` attr.
2024-08-20 01:07:21 +01:00

67 lines
1.5 KiB
Nix

{
makeNixvimWithModule,
lib ? pkgs.lib,
helpers,
pkgs,
pkgsUnfree,
}:
let
fetchTests = import ./fetch-tests.nix;
test-derivation = import ./test-derivation.nix { inherit pkgs lib makeNixvimWithModule; };
inherit (test-derivation) mkTestDerivationFromNixvimModule;
# List of files containing configurations
testFiles = fetchTests {
inherit lib pkgs helpers;
root = ./test-sources;
};
exampleFiles = {
name = "examples";
cases =
let
config = import ../example.nix { inherit pkgs; };
in
[
{
name = "main";
module = 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:
let
mkTest =
{ name, module }:
{
inherit name;
path = mkTestDerivationFromNixvimModule {
inherit name module;
pkgs = pkgsUnfree;
};
};
in
{
inherit (file) name;
path = pkgs.linkFarm file.name (builtins.map mkTest file.cases);
}
))
(helpers.groupListBySize 10)
(lib.imap1 (
i: group: rec {
name = "test-${toString i}";
value = pkgs.linkFarm name group;
}
))
builtins.listToAttrs
]