Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish: fix and enable fishConfig test #86802

Merged
merged 1 commit into from May 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 36 additions & 32 deletions pkgs/shells/fish/default.nix
Expand Up @@ -16,6 +16,7 @@
, python3
, cmake

, runCommand
, writeText
, nixosTests
, useOperatingSystemEtc ? true
Expand Down Expand Up @@ -202,38 +203,41 @@ let

passthru = {
shellPath = "/bin/fish";
tests.nixos = nixosTests.fish;
tests = {
nixos = nixosTests.fish;

# 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 *

# if we don't set `delete=False`, the file will get cleaned up
# automatically (leading the test to fail because there's no
# tempfile to check)
sed -e "s@, mode='w'@, mode='w', delete=False@" -i webconfig.py

# 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|.*\(/build/.*\)|\1|p' \
) | grep 'a href="http://localhost.*Start the Fish Web config'

# cannot test the http server because it needs a localhost port
'';
in
runCommand "test-web-config" { } ''
HOME=$(mktemp -d)
${fish}/bin/fish ${fishScript} && touch $out
'';
};
};
};

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 = with lib; flip const;
in
withTests tests fish
fish