Merge pull request #27971 from Profpatsch/fish-config-fix

Fish config fix
This commit is contained in:
Jörg Thalheim 2017-08-12 09:35:10 +01:00 committed by GitHub
commit e0e6f46cd8

View File

@ -1,7 +1,7 @@
{ stdenv, fetchurl, coreutils, utillinux, { stdenv, fetchurl, coreutils, utillinux,
nettools, kbd, bc, which, gnused, gnugrep, nettools, kbd, bc, which, gnused, gnugrep,
groff, man-db, glibc, libiconv, pcre2, groff, man-db, glibc, libiconv, pcre2,
gettext, ncurses, python gettext, ncurses, python3
, writeText , writeText
@ -85,9 +85,8 @@ let
$__extra_confdir $__extra_confdir
end end
''; '';
in
stdenv.mkDerivation rec { fish = stdenv.mkDerivation rec {
name = "fish-${version}"; name = "fish-${version}";
version = "2.6.0"; version = "2.6.0";
@ -105,7 +104,7 @@ stdenv.mkDerivation rec {
# Python: Autocompletion generated from manpages and config editing # Python: Autocompletion generated from manpages and config editing
propagatedBuildInputs = [ propagatedBuildInputs = [
coreutils gnugrep gnused bc coreutils gnugrep gnused bc
python groff gettext python3 groff gettext
] ++ optional (!stdenv.isDarwin) man-db; ] ++ optional (!stdenv.isDarwin) man-db;
postInstall = '' postInstall = ''
@ -132,8 +131,10 @@ stdenv.mkDerivation rec {
"$out/share/fish/functions/__fish_print_help.fish" "$out/share/fish/functions/__fish_print_help.fish"
sed -i "s|/sbin /usr/sbin||" \ sed -i "s|/sbin /usr/sbin||" \
"$out/share/fish/functions/__fish_complete_subcommand_root.fish" "$out/share/fish/functions/__fish_complete_subcommand_root.fish"
sed -e "s|clear;|${ncurses.out}/bin/clear;|" \ sed -e "s|clear;|${getBin ncurses}/bin/clear;|" \
-i "$out/share/fish/functions/fish_default_key_bindings.fish" \ -i "$out/share/fish/functions/fish_default_key_bindings.fish"
sed -e "s|python3|${getBin python3}/bin/python3|" \
-i $out/share/fish/functions/{__fish_config_interactive.fish,fish_config.fish,fish_update_completions.fish}
'' + optionalString stdenv.isLinux '' '' + optionalString stdenv.isLinux ''
sed -e "s| ul| ${utillinux}/bin/ul|" \ sed -e "s| ul| ${utillinux}/bin/ul|" \
@ -167,4 +168,35 @@ stdenv.mkDerivation rec {
passthru = { passthru = {
shellPath = "/bin/fish"; shellPath = "/bin/fish";
}; };
} };
tests = {
# Test the fish_config tool by checking the generated splash page.
# Since the webserver requires a port to run, it is not started.
fishConfig =
let fishScript = writeText "test.fish" ''
set -x __fish_bin_dir ${fish}/bin
echo $__fish_bin_dir
cp -r ${fish}/share/fish/tools/web_config/* .
chmod -R +w *
# we delete everything after the fileurl is assigned
sed -e '/fileurl =/q' -i webconfig.py
echo "print(fileurl)" >> webconfig.py
# and check whether the message appears on the page
cat (${python3}/bin/python ./webconfig.py \
| tail -n1 | sed -ne 's|.*\(/tmp/.*\)|\1|p' \
) | grep 'a href="http://localhost.*Start the Fish Web config'
# cannot test the http server because it needs a localhost port
'';
in ''
HOME=$(mktemp -d)
${fish}/bin/fish ${fishScript}
'';
};
# FIXME(Profpatsch) replace withTests stub
withTests = flip const;
in withTests tests fish