2023-03-22 07:42:02 +01:00
|
|
|
{
|
2024-02-15 14:27:45 +01:00
|
|
|
makeNixvimWithModule,
|
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,
|
2023-03-22 07:42:02 +01:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
fetchTests = import ./fetch-tests.nix;
|
2024-07-17 12:56:37 +02:00
|
|
|
test-derivation = import ./test-derivation.nix { inherit pkgs makeNixvimWithModule 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
|
|
|
|
|
|
|
# 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";
|
|
|
|
cases =
|
2024-01-04 22:02:23 +01:00
|
|
|
let
|
|
|
|
config = import ../example.nix { inherit pkgs; };
|
|
|
|
in
|
2024-07-17 14:16:00 +02:00
|
|
|
[
|
|
|
|
{
|
|
|
|
name = "main";
|
|
|
|
case = 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"
|
|
|
|
];
|
|
|
|
}
|
2024-01-04 22:02:23 +01:00
|
|
|
];
|
|
|
|
};
|
2024-07-19 20:22:19 +02:00
|
|
|
in
|
|
|
|
# We attempt to build & execute all configurations
|
|
|
|
builtins.listToAttrs (
|
|
|
|
builtins.map (
|
2024-07-17 14:16:00 +02:00
|
|
|
{ name, cases }:
|
2024-07-19 20:22:19 +02:00
|
|
|
|
2024-07-17 14:16:00 +02:00
|
|
|
let
|
|
|
|
# The test case can either be the actual definition,
|
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
|
|
|
# or a child attr named `module`.
|
2024-07-17 14:16:00 +02:00
|
|
|
prepareModule = case: case.module or (lib.removeAttrs case [ "tests" ]);
|
|
|
|
dontRunModule = case: case.tests.dontRun or false;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit name;
|
2024-07-19 20:22:19 +02:00
|
|
|
value = mkTestDerivationFromNixvimModule {
|
2024-07-17 14:16:00 +02:00
|
|
|
inherit name;
|
|
|
|
tests = builtins.map (
|
|
|
|
{ name, case }:
|
|
|
|
{
|
|
|
|
inherit name;
|
|
|
|
module = prepareModule case;
|
|
|
|
dontRun = dontRunModule case;
|
|
|
|
}
|
|
|
|
) cases;
|
|
|
|
# Use the global dontRun only if we don't have a list of modules
|
|
|
|
dontRun = dontRunModule cases;
|
|
|
|
pkgs = pkgsUnfree;
|
|
|
|
};
|
|
|
|
}
|
2024-07-19 20:22:19 +02:00
|
|
|
) (testFiles ++ [ exampleFiles ])
|
|
|
|
)
|