2024-10-18 09:44:59 +01:00
|
|
|
# Collects the various test modules in tests/test-sources/ and groups them into a number of test derivations
|
|
|
|
{
|
2024-10-17 19:59:37 +01:00
|
|
|
callTest,
|
2024-10-18 09:44:59 +01:00
|
|
|
helpers,
|
2024-10-17 19:59:37 +01:00
|
|
|
lib ? pkgs.lib,
|
2024-08-28 09:48:10 +01:00
|
|
|
linkFarm,
|
2024-10-18 09:44:59 +01:00
|
|
|
pkgs,
|
2024-10-17 18:55:05 +01:00
|
|
|
self,
|
2024-12-23 15:43:08 +00:00
|
|
|
system,
|
2024-10-18 09:44:59 +01:00
|
|
|
}:
|
|
|
|
let
|
2024-10-17 19:59:37 +01:00
|
|
|
fetchTests = callTest ./fetch-tests.nix { };
|
2025-03-24 22:48:48 +00:00
|
|
|
|
|
|
|
# Use a single common instance of nixpkgs, with allowUnfree
|
|
|
|
# Having a single shared instance should speed up tests a little
|
|
|
|
pkgsForTest = import self.inputs.nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = true;
|
2024-12-23 15:43:08 +00:00
|
|
|
};
|
2024-10-18 09:44:59 +01:00
|
|
|
|
|
|
|
moduleToTest =
|
|
|
|
file: name: module:
|
2025-03-24 22:48:48 +00:00
|
|
|
let
|
|
|
|
configuration = lib.nixvim.modules.evalNixvim {
|
|
|
|
modules = [
|
|
|
|
{
|
|
|
|
test.name = lib.mkDefault name;
|
|
|
|
_module.args.pkgs = lib.mkForce pkgsForTest;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
_file = file;
|
|
|
|
imports = lib.toList module;
|
|
|
|
}
|
|
|
|
];
|
2025-01-19 12:55:15 +00:00
|
|
|
};
|
2025-03-24 22:48:48 +00:00
|
|
|
in
|
2025-03-24 22:50:32 +00:00
|
|
|
configuration.config.build.test.overrideAttrs (old: {
|
|
|
|
passthru =
|
|
|
|
old.passthru or { }
|
2025-04-01 20:32:33 +01:00
|
|
|
// builtins.removeAttrs configuration [
|
|
|
|
"_type"
|
|
|
|
"type"
|
|
|
|
]
|
2025-03-24 22:50:32 +00:00
|
|
|
// {
|
|
|
|
inherit file module;
|
2025-04-01 20:32:33 +01:00
|
|
|
optionType = configuration.type;
|
2025-03-24 22:50:32 +00:00
|
|
|
};
|
|
|
|
});
|
2024-10-18 09:44:59 +01:00
|
|
|
|
|
|
|
# List of files containing configurations
|
|
|
|
testFiles = fetchTests ./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 (
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
file,
|
|
|
|
cases,
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
inherit name;
|
2024-08-28 09:48:10 +01:00
|
|
|
path = linkFarm name (builtins.mapAttrs (moduleToTest file) cases);
|
2024-10-18 09:44:59 +01:00
|
|
|
}
|
|
|
|
))
|
|
|
|
(helpers.groupListBySize 10)
|
|
|
|
(lib.imap1 (
|
|
|
|
i: group: rec {
|
|
|
|
name = "test-${toString i}";
|
2024-08-28 09:48:10 +01:00
|
|
|
value = linkFarm name group;
|
2024-10-18 09:44:59 +01:00
|
|
|
}
|
|
|
|
))
|
|
|
|
builtins.listToAttrs
|
|
|
|
]
|