Files
nixpkgs/pkgs/by-name/ly/lychee/tests/fail-emptyDirectory.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

33 lines
1.2 KiB
Nix

{
runCommand,
testers,
emptyDirectory,
}:
let
sitePkg = runCommand "site" { } ''
dist=$out/dist
mkdir -p $dist
echo "<html><body><a href=\"https://example.com/foo\">foo</a></body></html>" > $dist/index.html
echo "<html><body></body></html>" > $dist/foo.html
'';
check = testers.lycheeLinkCheck {
site = sitePkg + "/dist";
remap = {
# Normally would recommend to append a subpath that hints why it's forbidden; see example in docs.
# However, we also want to test that a package is converted to a string *before*
# it's tested whether it's a store path. Mistake made during development caused:
# cannot check URI: InvalidUrlRemap("The remapping pattern must produce a valid URL, but it is not: /nix/store/4d0ix...empty-directory/foo
"https://example.com" = emptyDirectory;
};
};
failure = testers.testBuildFailure check;
in
runCommand "link-check-fail" { inherit failure; } ''
# The details of the message might change, but we have to make sure the
# correct error is reported, so that we know it's not something else that
# went wrong.
grep 'empty-directory/foo.*Cannot find file' $failure/testBuildFailure.log >/dev/null
touch $out
''