2024-08-20 00:30:16 +01:00
|
|
|
{
|
2024-12-15 06:51:20 +00:00
|
|
|
self,
|
2024-12-23 15:43:08 +00:00
|
|
|
system,
|
|
|
|
lib,
|
2024-08-20 00:30:16 +01:00
|
|
|
}:
|
2023-03-22 07:42:02 +01:00
|
|
|
let
|
2024-12-23 15:43:08 +00:00
|
|
|
defaultSystem = system;
|
2024-08-25 16:13:23 +01:00
|
|
|
|
2023-03-22 07:42:02 +01:00
|
|
|
# Create a nix derivation from a nixvim executable.
|
|
|
|
# The build phase simply consists in running the provided nvim binary.
|
|
|
|
mkTestDerivationFromNvim =
|
|
|
|
{
|
2023-03-03 09:18:52 +00:00
|
|
|
name,
|
2024-08-18 20:17:14 +01:00
|
|
|
nvim,
|
2023-03-03 09:18:52 +00:00
|
|
|
...
|
2024-12-23 10:45:55 +01:00
|
|
|
}:
|
2024-08-20 00:30:16 +01:00
|
|
|
let
|
2024-08-05 12:21:24 +01:00
|
|
|
# FIXME: this doesn't support helpers.enableExceptInTests, a context option would be better
|
|
|
|
result = nvim.extend {
|
2024-12-23 10:45:55 +01:00
|
|
|
config.test = {
|
|
|
|
inherit name;
|
|
|
|
};
|
2024-08-05 12:21:24 +01:00
|
|
|
};
|
2024-08-20 00:30:16 +01:00
|
|
|
in
|
2024-09-24 07:02:22 +01:00
|
|
|
result.config.build.test;
|
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
|
|
|
# Create a nix derivation from a nixvim configuration.
|
|
|
|
# The build phase simply consists in running neovim with the given configuration.
|
2024-02-15 14:27:45 +01:00
|
|
|
mkTestDerivationFromNixvimModule =
|
|
|
|
{
|
2024-08-05 12:21:24 +01:00
|
|
|
name ? null,
|
2024-12-23 14:44:23 +00:00
|
|
|
pkgs ? null,
|
2024-12-23 15:43:08 +00:00
|
|
|
system ? defaultSystem,
|
2024-08-18 20:17:14 +01:00
|
|
|
module,
|
2024-02-15 14:27:45 +01:00
|
|
|
extraSpecialArgs ? { },
|
2024-12-23 10:45:55 +01:00
|
|
|
}:
|
2024-02-15 14:27:45 +01:00
|
|
|
let
|
2024-12-15 05:23:06 +00:00
|
|
|
# NOTE: we are importing this just for evalNixvim
|
2024-12-21 13:40:16 +00:00
|
|
|
helpers = self.lib.nixvim.override {
|
2024-08-05 12:21:24 +01:00
|
|
|
# TODO: deprecate helpers.enableExceptInTests,
|
|
|
|
# add a context option e.g. `config.isTest`?
|
2024-08-18 20:17:14 +01:00
|
|
|
_nixvimTests = true;
|
2024-08-05 12:21:24 +01:00
|
|
|
};
|
|
|
|
|
2024-12-23 14:44:23 +00:00
|
|
|
systemMod =
|
|
|
|
if pkgs == null then
|
|
|
|
{ nixpkgs.hostPlatform = lib.mkDefault { inherit system; }; }
|
|
|
|
else
|
|
|
|
{ nixpkgs.pkgs = lib.mkDefault pkgs; };
|
|
|
|
|
2024-08-05 12:21:24 +01:00
|
|
|
result = helpers.modules.evalNixvim {
|
|
|
|
modules = [
|
|
|
|
module
|
|
|
|
(lib.optionalAttrs (name != null) { test.name = name; })
|
2024-08-24 19:55:13 +01:00
|
|
|
{ wrapRc = true; }
|
2024-12-23 14:44:23 +00:00
|
|
|
systemMod
|
2024-08-05 12:21:24 +01:00
|
|
|
];
|
2024-08-14 05:31:27 +01:00
|
|
|
inherit extraSpecialArgs;
|
2024-08-18 20:17:14 +01:00
|
|
|
};
|
2024-02-15 14:27:45 +01:00
|
|
|
in
|
2024-09-24 07:02:22 +01:00
|
|
|
result.config.build.test;
|
2023-05-15 11:04:52 +02:00
|
|
|
in
|
2024-09-13 14:44:42 +01:00
|
|
|
# NOTE: this is exported publicly in the flake outputs as `lib.<system>.check`
|
2023-05-15 11:04:52 +02: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
|
|
|
inherit mkTestDerivationFromNvim mkTestDerivationFromNixvimModule;
|
2023-05-15 11:04:52 +02:00
|
|
|
}
|