mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-02 17:15:01 +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.
This commit is contained in:
parent
049bbc168f
commit
10f64e6c96
4 changed files with 28 additions and 47 deletions
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
makeNixvim,
|
||||
makeNixvimWithModule,
|
||||
}:
|
||||
{ pkgs, makeNixvimWithModule, ... }:
|
||||
let
|
||||
# Create a nix derivation from a nixvim executable.
|
||||
# The build phase simply consists in running the provided nvim binary.
|
||||
|
@ -46,12 +42,15 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
# Create a nix derivation from a nixvim configuration.
|
||||
# The build phase simply consists in running neovim with the given configuration.
|
||||
mkTestDerivationFromNixvimModule =
|
||||
{
|
||||
name ? "nixvim-check",
|
||||
pkgs,
|
||||
pkgs ? pkgs,
|
||||
module,
|
||||
extraSpecialArgs ? { },
|
||||
dontRun ? false,
|
||||
}:
|
||||
let
|
||||
nvim = makeNixvimWithModule {
|
||||
|
@ -59,21 +58,8 @@ let
|
|||
_nixvimTests = true;
|
||||
};
|
||||
in
|
||||
mkTestDerivationFromNvim { inherit name nvim; };
|
||||
|
||||
# Create a nix derivation from a nixvim configuration.
|
||||
# The build phase simply consists in running neovim with the given configuration.
|
||||
mkTestDerivation =
|
||||
name: config:
|
||||
let
|
||||
testAttributes = if builtins.hasAttr "tests" config then config.tests else { dontRun = false; };
|
||||
nvim = makeNixvim (pkgs.lib.attrsets.filterAttrs (n: _: n != "tests") config);
|
||||
in
|
||||
mkTestDerivationFromNvim {
|
||||
inherit name nvim;
|
||||
inherit (testAttributes) dontRun;
|
||||
};
|
||||
mkTestDerivationFromNvim { inherit name nvim dontRun; };
|
||||
in
|
||||
{
|
||||
inherit mkTestDerivation mkTestDerivationFromNvim mkTestDerivationFromNixvimModule;
|
||||
inherit mkTestDerivationFromNvim mkTestDerivationFromNixvimModule;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue