mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/test: move from tests/test-derivation
This commit is contained in:
parent
cbd1003d9d
commit
19d5f4b134
3 changed files with 2 additions and 2 deletions
|
@ -7,6 +7,6 @@
|
|||
}@args:
|
||||
{
|
||||
# Add all exported modules here
|
||||
check = import ../tests/test-derivation.nix { inherit lib pkgs; };
|
||||
check = import ./tests.nix { inherit lib pkgs; };
|
||||
helpers = import ./helpers.nix (args // { inherit _nixvimTests; });
|
||||
}
|
||||
|
|
71
lib/tests.nix
Normal file
71
lib/tests.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
pkgs,
|
||||
lib ? pkgs.lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# Create a nix derivation from a nixvim executable.
|
||||
# The build phase simply consists in running the provided nvim binary.
|
||||
mkTestDerivationFromNvim =
|
||||
{
|
||||
name,
|
||||
nvim,
|
||||
# TODO: Deprecated 2024-08-20, remove after 24.11
|
||||
dontRun ? false,
|
||||
...
|
||||
}@args:
|
||||
let
|
||||
# FIXME: this doesn't support helpers.enableExceptInTests, a context option would be better
|
||||
result = nvim.extend {
|
||||
config.test =
|
||||
{
|
||||
inherit name;
|
||||
}
|
||||
// lib.optionalAttrs (args ? dontRun) (
|
||||
lib.warn
|
||||
"mkTestDerivationFromNvim: the `dontRun` argument is deprecated. You should use the `test.runNvim` module option instead."
|
||||
{ runNvim = !dontRun; }
|
||||
);
|
||||
};
|
||||
in
|
||||
result.config.test.derivation;
|
||||
|
||||
# Create a nix derivation from a nixvim configuration.
|
||||
# The build phase simply consists in running neovim with the given configuration.
|
||||
mkTestDerivationFromNixvimModule =
|
||||
{
|
||||
name ? null,
|
||||
pkgs ? pkgs,
|
||||
module,
|
||||
extraSpecialArgs ? { },
|
||||
# TODO: Deprecated 2024-08-20, remove after 24.11
|
||||
dontRun ? false,
|
||||
}@args:
|
||||
let
|
||||
helpers = import ../lib/helpers.nix {
|
||||
inherit pkgs lib;
|
||||
# TODO: deprecate helpers.enableExceptInTests,
|
||||
# add a context option e.g. `config.isTest`?
|
||||
_nixvimTests = true;
|
||||
};
|
||||
|
||||
result = helpers.modules.evalNixvim {
|
||||
modules = [
|
||||
module
|
||||
(lib.optionalAttrs (name != null) { test.name = name; })
|
||||
(lib.optionalAttrs (args ? dontRun) (
|
||||
lib.warn
|
||||
"mkTestDerivationFromNixvimModule: the `dontRun` argument is deprecated. You should use the `test.runNvim` module option instead."
|
||||
{ config.test.runNvim = !dontRun; }
|
||||
))
|
||||
];
|
||||
extraSpecialArgs = {
|
||||
defaultPkgs = pkgs;
|
||||
} // extraSpecialArgs;
|
||||
};
|
||||
in
|
||||
result.config.test.derivation;
|
||||
in
|
||||
{
|
||||
inherit mkTestDerivationFromNvim mkTestDerivationFromNixvimModule;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue