mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-13 18:54:30 +02:00
modules/test: switch to runCommand
This commit is contained in:
parent
1085bcd7cc
commit
af31063538
1 changed files with 42 additions and 47 deletions
|
@ -46,54 +46,49 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config =
|
||||||
test.derivation = pkgs.stdenv.mkDerivation {
|
let
|
||||||
inherit (cfg) name;
|
showErr =
|
||||||
dontUnpack = true;
|
name: lines:
|
||||||
|
lib.optionalString (lines != [ ]) ''
|
||||||
nativeBuildInputs = [ config.finalPackage ];
|
Unexpected ${name}:
|
||||||
|
${lib.concatStringsSep "\n" (lib.map (v: "- ${v}") lines)}
|
||||||
# First check warnings/assertions, then run nvim
|
|
||||||
buildPhase =
|
|
||||||
let
|
|
||||||
showErr =
|
|
||||||
name: lines:
|
|
||||||
lib.optionalString (lines != [ ]) ''
|
|
||||||
Unexpected ${name}:
|
|
||||||
${lib.concatStringsSep "\n" (lib.map (v: "- ${v}") lines)}
|
|
||||||
'';
|
|
||||||
|
|
||||||
toCheck =
|
|
||||||
lib.optionalAttrs cfg.checkWarnings { inherit warnings; }
|
|
||||||
// lib.optionalAttrs cfg.checkAssertions { inherit assertions; };
|
|
||||||
|
|
||||||
errors = lib.foldlAttrs (
|
|
||||||
err: name: lines:
|
|
||||||
err + showErr name lines
|
|
||||||
) "" toCheck;
|
|
||||||
in
|
|
||||||
lib.optionalString (errors != "") ''
|
|
||||||
echo -n ${lib.escapeShellArg errors}
|
|
||||||
exit 1
|
|
||||||
''
|
|
||||||
# We need to set HOME because neovim will try to create some files
|
|
||||||
#
|
|
||||||
# Because neovim does not return an exitcode when quitting we need to check if there are
|
|
||||||
# errors on stderr
|
|
||||||
+ lib.optionalString cfg.runNvim ''
|
|
||||||
mkdir -p .cache/nvim
|
|
||||||
|
|
||||||
output=$(HOME=$(realpath .) nvim -mn --headless "+q" 2>&1 >/dev/null)
|
|
||||||
if [[ -n $output ]]; then
|
|
||||||
echo "ERROR: $output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# If we don't do this nix is not happy
|
toCheck =
|
||||||
installPhase = ''
|
lib.optionalAttrs cfg.checkWarnings { inherit warnings; }
|
||||||
touch $out
|
// lib.optionalAttrs cfg.checkAssertions { inherit assertions; };
|
||||||
'';
|
|
||||||
|
errors = lib.foldlAttrs (
|
||||||
|
err: name: lines:
|
||||||
|
err + showErr name lines
|
||||||
|
) "" toCheck;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
test.derivation =
|
||||||
|
pkgs.runCommandNoCCLocal cfg.name { nativeBuildInputs = [ config.finalPackage ]; }
|
||||||
|
(
|
||||||
|
# First check warnings/assertions, then run nvim
|
||||||
|
lib.optionalString (errors != "") ''
|
||||||
|
echo -n ${lib.escapeShellArg errors}
|
||||||
|
exit 1
|
||||||
|
''
|
||||||
|
# We need to set HOME because neovim will try to create some files
|
||||||
|
#
|
||||||
|
# Because neovim does not return an exitcode when quitting we need to check if there are
|
||||||
|
# errors on stderr
|
||||||
|
+ lib.optionalString cfg.runNvim ''
|
||||||
|
mkdir -p .cache/nvim
|
||||||
|
|
||||||
|
output=$(HOME=$(realpath .) nvim -mn --headless "+q" 2>&1 >/dev/null)
|
||||||
|
if [[ -n $output ]]; then
|
||||||
|
echo "ERROR: $output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
''
|
||||||
|
+ ''
|
||||||
|
touch $out
|
||||||
|
''
|
||||||
|
);
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue