fish: fix and enable fishConfig
test
`nix-build -A fish.tests.fishConfig` will now test that the `fish_config` tool would start up properly. Previously, this test was effectively disabled due to `withTests` being stubbed out. I don't think this test ever truly worked, because the generated temporary file would be cleaned up automatically (or maybe this "automatically" changed between versions). The solution to this is to add `delete=False` to the `NamedTemporaryFile` function call, to keep the temporary file around in order to grep its contents for the expected output.
This commit is contained in:
parent
5cf57c4679
commit
a17630204a
@ -16,6 +16,7 @@
|
||||
, python3
|
||||
, cmake
|
||||
|
||||
, runCommand
|
||||
, writeText
|
||||
, nixosTests
|
||||
, useOperatingSystemEtc ? true
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user