tests: Allow to skip running neovim (#260)

Some plugins don't really play nicely with being launched in a headless
sandboxed environment. This adds the pseudo option 'tests.dontRun' to
avoid running those tests
This commit is contained in:
traxys 2023-03-16 09:13:43 +01:00 committed by GitHub
parent 2a3d497d29
commit f5f33b5390
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 9 deletions

View file

@ -2,6 +2,7 @@
checkNvim = {
name,
nvim,
dontRun,
...
}:
pkgs.stdenv.mkDerivation {
@ -14,12 +15,16 @@
#
# Because neovim does not return an exitcode when quitting we need to check if there are
# errors on stderr
buildPhase = ''
buildPhase =
if !dontRun
then ''
output=$(HOME=$(realpath .) nvim -mn --headless "+q" 2>&1 >/dev/null)
if [[ -n $output ]]; then
echo "ERROR: $output"
exit 1
fi
''
else ''
'';
# If we don't do this nix is not happy

View file

@ -9,8 +9,17 @@ in
# We attempt to build & execute all configurations
builtins.mapAttrs (
name: config: let
nvim = makeNixvim config;
testAttributes =
if builtins.hasAttr "tests" config
then config.tests
else {
dontRun = false;
};
nvim = makeNixvim (pkgs.lib.attrsets.filterAttrs (n: _: n != "tests") config);
in
checkConfig {inherit name nvim;}
checkConfig {
inherit name nvim;
inherit (testAttributes) dontRun;
}
)
tests