installShellFiles: nixfmt-rfc-style

This commit is contained in:
Anderson Torres 2024-08-14 11:59:49 -03:00
parent f72e74d7ae
commit 8b674370c4
2 changed files with 62 additions and 41 deletions

View File

@ -4,9 +4,8 @@
let
setupHook = makeSetupHook { name = "install-shell-files"; } ./setup-hook.sh;
in
setupHook.overrideAttrs (oldAttrs: {
passthru = (oldAttrs.passthru or {}) // {
passthru = (oldAttrs.passthru or { }) // {
tests = callPackage ./tests { };
};
})

View File

@ -1,17 +1,26 @@
{ lib, runCommandLocal, recurseIntoAttrs, installShellFiles }:
{
lib,
runCommandLocal,
recurseIntoAttrs,
installShellFiles,
}:
let
runTest = name: env: buildCommand:
runCommandLocal "install-shell-files--${name}" ({
nativeBuildInputs = [ installShellFiles ];
meta.platforms = lib.platforms.all;
} // env) buildCommand;
runTest =
name: env: buildCommand:
runCommandLocal "install-shell-files--${name}" (
{
nativeBuildInputs = [ installShellFiles ];
meta.platforms = lib.platforms.all;
}
// env
) buildCommand;
in
recurseIntoAttrs {
# installManPage
install-manpage = runTest "install-manpage" {} ''
install-manpage = runTest "install-manpage" { } ''
mkdir -p doc
echo foo > doc/foo.1
echo bar > doc/bar.2.gz
@ -23,32 +32,39 @@ recurseIntoAttrs {
cmp doc/bar.2.gz $out/share/man/man2/bar.2.gz
cmp doc/baz.3 $out/share/man/man3/baz.3
'';
install-manpage-outputs = runTest "install-manpage-outputs" {
outputs = [ "out" "man" "devman" ];
} ''
mkdir -p doc
echo foo > doc/foo.1
echo bar > doc/bar.3
install-manpage-outputs =
runTest "install-manpage-outputs"
{
outputs = [
"out"
"man"
"devman"
];
}
''
mkdir -p doc
echo foo > doc/foo.1
echo bar > doc/bar.3
installManPage doc/*
installManPage doc/*
# assert they didn't go into $out
[[ ! -f $out/share/man/man1/foo.1 && ! -f $out/share/man/man3/bar.3 ]]
# assert they didn't go into $out
[[ ! -f $out/share/man/man1/foo.1 && ! -f $out/share/man/man3/bar.3 ]]
# foo.1 alone went into man
cmp doc/foo.1 ''${!outputMan:?}/share/man/man1/foo.1
[[ ! -f ''${!outputMan:?}/share/man/man3/bar.3 ]]
# foo.1 alone went into man
cmp doc/foo.1 ''${!outputMan:?}/share/man/man1/foo.1
[[ ! -f ''${!outputMan:?}/share/man/man3/bar.3 ]]
# bar.3 alone went into devman
cmp doc/bar.3 ''${!outputDevman:?}/share/man/man3/bar.3
[[ ! -f ''${!outputDevman:?}/share/man/man1/foo.1 ]]
# bar.3 alone went into devman
cmp doc/bar.3 ''${!outputDevman:?}/share/man/man3/bar.3
[[ ! -f ''${!outputDevman:?}/share/man/man1/foo.1 ]]
touch $out
'';
touch $out
'';
# installShellCompletion
install-completion = runTest "install-completion" {} ''
install-completion = runTest "install-completion" { } ''
echo foo > foo
echo bar > bar
echo baz > baz
@ -63,21 +79,27 @@ recurseIntoAttrs {
cmp qux.zsh $out/share/zsh/site-functions/_qux
cmp quux $out/share/fish/vendor_completions.d/quux
'';
install-completion-output = runTest "install-completion-output" {
outputs = [ "out" "bin" ];
} ''
echo foo > foo
install-completion-output =
runTest "install-completion-output"
{
outputs = [
"out"
"bin"
];
}
''
echo foo > foo
installShellCompletion --bash foo
installShellCompletion --bash foo
# assert it didn't go into $out
[[ ! -f $out/share/bash-completion/completions/foo ]]
# assert it didn't go into $out
[[ ! -f $out/share/bash-completion/completions/foo ]]
cmp foo ''${!outputBin:?}/share/bash-completion/completions/foo
cmp foo ''${!outputBin:?}/share/bash-completion/completions/foo
touch $out
'';
install-completion-name = runTest "install-completion-name" {} ''
touch $out
'';
install-completion-name = runTest "install-completion-name" { } ''
echo foo > foo
echo bar > bar
echo baz > baz
@ -88,7 +110,7 @@ recurseIntoAttrs {
cmp bar $out/share/zsh/site-functions/_foobar
cmp baz $out/share/fish/vendor_completions.d/baz
'';
install-completion-inference = runTest "install-completion-inference" {} ''
install-completion-inference = runTest "install-completion-inference" { } ''
echo foo > foo.bash
echo bar > bar.zsh
echo baz > baz.fish
@ -99,7 +121,7 @@ recurseIntoAttrs {
cmp bar.zsh $out/share/zsh/site-functions/_bar
cmp baz.fish $out/share/fish/vendor_completions.d/baz.fish
'';
install-completion-cmd = runTest "install-completion-cmd" {} ''
install-completion-cmd = runTest "install-completion-cmd" { } ''
echo foo > foo.bash
echo bar > bar.zsh
echo baz > baz.fish
@ -112,7 +134,7 @@ recurseIntoAttrs {
cmp baz.fish $out/share/fish/vendor_completions.d/foobar.fish
cmp qux.fish $out/share/fish/vendor_completions.d/qux
'';
install-completion-fifo = runTest "install-completion-fifo" {} ''
install-completion-fifo = runTest "install-completion-fifo" { } ''
installShellCompletion \
--bash --name foo.bash <(echo foo) \
--zsh --name _foo <(echo bar) \