2023-03-22 07:42:02 +01:00
|
|
|
{
|
tests/test-derivation: allow tests to be modules
Use `mkTestDerivationFromNixvimModule` instead of `mkTestDerivation`,
allowing "proper" modules to be used instead of plain attr configs.
This is useful for more complex tests that wish to use `config` or
`options` arguments, e.g:
```nix
{config, options, ...}: {
/* some cool test */
}
```
To allow `tests.dontRun` to be defined on such a test, the module is
allowed to be nested as `module`, e.g:
```nix
{
tests.dontRun = true;
module = {config, options, ...}: {
/* a disabled test */
};
}
```
Also ended up doing some general cleanup, removing an unused function,
etc.
2024-06-29 20:16:16 +01:00
|
|
|
lib ? pkgs.lib,
|
2024-02-09 15:03:32 +01:00
|
|
|
helpers,
|
2023-03-22 07:42:02 +01:00
|
|
|
pkgs,
|
tests/test-derivation: allow tests to be modules
Use `mkTestDerivationFromNixvimModule` instead of `mkTestDerivation`,
allowing "proper" modules to be used instead of plain attr configs.
This is useful for more complex tests that wish to use `config` or
`options` arguments, e.g:
```nix
{config, options, ...}: {
/* some cool test */
}
```
To allow `tests.dontRun` to be defined on such a test, the module is
allowed to be nested as `module`, e.g:
```nix
{
tests.dontRun = true;
module = {config, options, ...}: {
/* a disabled test */
};
}
```
Also ended up doing some general cleanup, removing an unused function,
etc.
2024-06-29 20:16:16 +01:00
|
|
|
pkgsUnfree,
|
2024-05-05 19:39:35 +02:00
|
|
|
}:
|
|
|
|
let
|
2023-03-22 07:42:02 +01:00
|
|
|
fetchTests = import ./fetch-tests.nix;
|
2024-08-05 17:40:18 +01:00
|
|
|
test-derivation = import ../lib/tests.nix { inherit pkgs lib; };
|
tests/test-derivation: allow tests to be modules
Use `mkTestDerivationFromNixvimModule` instead of `mkTestDerivation`,
allowing "proper" modules to be used instead of plain attr configs.
This is useful for more complex tests that wish to use `config` or
`options` arguments, e.g:
```nix
{config, options, ...}: {
/* some cool test */
}
```
To allow `tests.dontRun` to be defined on such a test, the module is
allowed to be nested as `module`, e.g:
```nix
{
tests.dontRun = true;
module = {config, options, ...}: {
/* a disabled test */
};
}
```
Also ended up doing some general cleanup, removing an unused function,
etc.
2024-06-29 20:16:16 +01:00
|
|
|
inherit (test-derivation) mkTestDerivationFromNixvimModule;
|
2023-03-22 07:42:02 +01:00
|
|
|
|
2024-08-22 13:46:05 +01:00
|
|
|
mkTest =
|
|
|
|
{ name, module }:
|
|
|
|
{
|
|
|
|
inherit name;
|
|
|
|
path = mkTestDerivationFromNixvimModule {
|
|
|
|
inherit name module;
|
|
|
|
pkgs = pkgsUnfree;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-03-22 07:42:02 +01:00
|
|
|
# List of files containing configurations
|
|
|
|
testFiles = fetchTests {
|
2024-02-09 15:03:32 +01:00
|
|
|
inherit lib pkgs helpers;
|
2023-03-22 07:42:02 +01:00
|
|
|
root = ./test-sources;
|
|
|
|
};
|
2024-01-04 22:02:23 +01:00
|
|
|
|
|
|
|
exampleFiles = {
|
2024-07-17 14:16:00 +02:00
|
|
|
name = "examples";
|
2024-08-22 13:46:05 +01:00
|
|
|
modules =
|
2024-05-05 19:39:35 +02:00
|
|
|
let
|
|
|
|
config = import ../example.nix { inherit pkgs; };
|
|
|
|
in
|
2024-07-17 14:16:00 +02:00
|
|
|
[
|
|
|
|
{
|
|
|
|
name = "main";
|
2024-08-20 00:54:50 +01:00
|
|
|
module = builtins.removeAttrs config.programs.nixvim [
|
2024-07-17 14:16:00 +02:00
|
|
|
# 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"
|
|
|
|
];
|
|
|
|
}
|
2024-01-04 22:02:23 +01:00
|
|
|
];
|
|
|
|
};
|
2024-07-19 20:22:19 +02:00
|
|
|
in
|
|
|
|
# We attempt to build & execute all configurations
|
2024-08-19 01:11:10 +01:00
|
|
|
lib.pipe (testFiles ++ [ exampleFiles ]) [
|
2024-08-22 13:46:05 +01:00
|
|
|
(builtins.map (file: {
|
|
|
|
inherit (file) name;
|
|
|
|
path = pkgs.linkFarm file.name (builtins.map mkTest file.modules);
|
|
|
|
}))
|
2024-08-19 01:11:10 +01:00
|
|
|
(helpers.groupListBySize 10)
|
|
|
|
(lib.imap1 (
|
|
|
|
i: group: rec {
|
|
|
|
name = "test-${toString i}";
|
|
|
|
value = pkgs.linkFarm name group;
|
2024-07-17 14:16:00 +02:00
|
|
|
}
|
2024-08-19 01:11:10 +01:00
|
|
|
))
|
|
|
|
builtins.listToAttrs
|
|
|
|
]
|