Files
nixpkgs/pkgs/by-name/ly/lychee/tests/fail-rootRelative.nix
Robert Hensing fb0d18ee0b testers.lycheeLinkCheck: improve root-relative link UX
Lychee by itself does not have a way to explicitly declare the
intent for the site to be relocatable.
Recent-ish changes in lychee and/or its dependencies have made
it catch the a root reference in all mdbook 404.html pages,
which is quite confusing.
By improving the UX around this aspect of the site, we resolve
at least part of that confusion.
(Though mdbook users should probably exclude the 404 page)
2026-05-16 12:35:07 +02:00

22 lines
662 B
Nix

{ runCommand, testers }:
let
sitePkg = runCommand "site" { } ''
dist=$out/dist
mkdir -p $dist
echo "<html><body>hi</body></html>" > $dist/index.html
echo "<html><body><a href=\"/index.html\">home</a></body></html>" > $dist/page.html
'';
linkCheck = testers.lycheeLinkCheck {
site = sitePkg + "/dist";
};
failure = testers.testBuildFailure linkCheck;
in
runCommand "link-check-fail" { inherit failure; } ''
grep -F "root-relative-links-are-forbidden-use-relative-links/index.html" $failure/testBuildFailure.log >/dev/null
grep -F "Please set the relocatable parameter" $failure/testBuildFailure.log >/dev/null
touch $out
''