diff --git a/pkgs/by-name/in/installShellFiles/package.nix b/pkgs/by-name/in/installShellFiles/package.nix index 12595850c393..87787ad872ee 100644 --- a/pkgs/by-name/in/installShellFiles/package.nix +++ b/pkgs/by-name/in/installShellFiles/package.nix @@ -1,4 +1,8 @@ -{ callPackage, makeSetupHook }: +{ + lib, + callPackage, + makeSetupHook, +}: # See the header comment in ./setup-hook.sh for example usage. let @@ -6,6 +10,9 @@ let in setupHook.overrideAttrs (oldAttrs: { passthru = (oldAttrs.passthru or { }) // { - tests = callPackage ./tests { }; + tests = lib.packagesFromDirectoryRecursive { + inherit callPackage; + directory = ./tests; + }; }; }) diff --git a/pkgs/by-name/in/installShellFiles/tests/default.nix b/pkgs/by-name/in/installShellFiles/tests/default.nix deleted file mode 100644 index 456edc5c6330..000000000000 --- a/pkgs/by-name/in/installShellFiles/tests/default.nix +++ /dev/null @@ -1,147 +0,0 @@ -{ - lib, - runCommandLocal, - recurseIntoAttrs, - installShellFiles, -}: - -let - 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" { } '' - mkdir -p doc - echo foo > doc/foo.1 - echo bar > doc/bar.2.gz - echo baz > doc/baz.3 - - installManPage doc/* - - cmp doc/foo.1 $out/share/man/man1/foo.1 - 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 - - installManPage doc/* - - # 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 ]] - - # 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 - ''; - - # installShellCompletion - - install-completion = runTest "install-completion" { } '' - echo foo > foo - echo bar > bar - echo baz > baz - echo qux > qux.zsh - echo quux > quux - - installShellCompletion --bash foo bar --zsh baz qux.zsh --fish quux - - cmp foo $out/share/bash-completion/completions/foo - cmp bar $out/share/bash-completion/completions/bar - cmp baz $out/share/zsh/site-functions/_baz - 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 - - installShellCompletion --bash foo - - # assert it didn't go into $out - [[ ! -f $out/share/bash-completion/completions/foo ]] - - cmp foo ''${!outputBin:?}/share/bash-completion/completions/foo - - touch $out - ''; - install-completion-name = runTest "install-completion-name" { } '' - echo foo > foo - echo bar > bar - echo baz > baz - - installShellCompletion --bash --name foobar.bash foo --zsh --name _foobar bar --fish baz - - cmp foo $out/share/bash-completion/completions/foobar.bash - cmp bar $out/share/zsh/site-functions/_foobar - cmp baz $out/share/fish/vendor_completions.d/baz - ''; - install-completion-inference = runTest "install-completion-inference" { } '' - echo foo > foo.bash - echo bar > bar.zsh - echo baz > baz.fish - - installShellCompletion foo.bash bar.zsh baz.fish - - cmp foo.bash $out/share/bash-completion/completions/foo.bash - 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" { } '' - echo foo > foo.bash - echo bar > bar.zsh - echo baz > baz.fish - echo qux > qux.fish - - installShellCompletion --cmd foobar --bash foo.bash --zsh bar.zsh --fish baz.fish --name qux qux.fish - - cmp foo.bash $out/share/bash-completion/completions/foobar.bash - cmp bar.zsh $out/share/zsh/site-functions/_foobar - 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" { } '' - installShellCompletion \ - --bash --name foo.bash <(echo foo) \ - --zsh --name _foo <(echo bar) \ - --fish --name foo.fish <(echo baz) - - [[ $(<$out/share/bash-completion/completions/foo.bash) == foo ]] || { echo "foo.bash comparison failed"; exit 1; } - [[ $(<$out/share/zsh/site-functions/_foo) == bar ]] || { echo "_foo comparison failed"; exit 1; } - [[ $(<$out/share/fish/vendor_completions.d/foo.fish) == baz ]] || { echo "foo.fish comparison failed"; exit 1; } - ''; -} diff --git a/pkgs/by-name/in/installShellFiles/tests/install-completion-cmd.nix b/pkgs/by-name/in/installShellFiles/tests/install-completion-cmd.nix new file mode 100644 index 000000000000..a8687ccc2c7d --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-completion-cmd.nix @@ -0,0 +1,24 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-completion-cmd" + { + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + echo foo > foo.bash + echo bar > bar.zsh + echo baz > baz.fish + echo qux > qux.fish + + installShellCompletion --cmd foobar --bash foo.bash --zsh bar.zsh --fish baz.fish --name qux qux.fish + + cmp foo.bash $out/share/bash-completion/completions/foobar.bash + cmp bar.zsh $out/share/zsh/site-functions/_foobar + cmp baz.fish $out/share/fish/vendor_completions.d/foobar.fish + cmp qux.fish $out/share/fish/vendor_completions.d/qux + '' diff --git a/pkgs/by-name/in/installShellFiles/tests/install-completion-fifo.nix b/pkgs/by-name/in/installShellFiles/tests/install-completion-fifo.nix new file mode 100644 index 000000000000..2c777f0fb68a --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-completion-fifo.nix @@ -0,0 +1,21 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-completion-fifo" + { + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + installShellCompletion \ + --bash --name foo.bash <(echo foo) \ + --zsh --name _foo <(echo bar) \ + --fish --name foo.fish <(echo baz) + + [[ $(<$out/share/bash-completion/completions/foo.bash) == foo ]] || { echo "foo.bash comparison failed"; exit 1; } + [[ $(<$out/share/zsh/site-functions/_foo) == bar ]] || { echo "_foo comparison failed"; exit 1; } + [[ $(<$out/share/fish/vendor_completions.d/foo.fish) == baz ]] || { echo "foo.fish comparison failed"; exit 1; } + '' diff --git a/pkgs/by-name/in/installShellFiles/tests/install-completion-inference.nix b/pkgs/by-name/in/installShellFiles/tests/install-completion-inference.nix new file mode 100644 index 000000000000..9a51965ccecb --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-completion-inference.nix @@ -0,0 +1,22 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-completion-inference" + { + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + echo foo > foo.bash + echo bar > bar.zsh + echo baz > baz.fish + + installShellCompletion foo.bash bar.zsh baz.fish + + cmp foo.bash $out/share/bash-completion/completions/foo.bash + cmp bar.zsh $out/share/zsh/site-functions/_bar + cmp baz.fish $out/share/fish/vendor_completions.d/baz.fish + '' diff --git a/pkgs/by-name/in/installShellFiles/tests/install-completion-name.nix b/pkgs/by-name/in/installShellFiles/tests/install-completion-name.nix new file mode 100644 index 000000000000..2473318dee2c --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-completion-name.nix @@ -0,0 +1,22 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-completion-name" + { + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + echo foo > foo + echo bar > bar + echo baz > baz + + installShellCompletion --bash --name foobar.bash foo --zsh --name _foobar bar --fish baz + + cmp foo $out/share/bash-completion/completions/foobar.bash + cmp bar $out/share/zsh/site-functions/_foobar + cmp baz $out/share/fish/vendor_completions.d/baz + '' diff --git a/pkgs/by-name/in/installShellFiles/tests/install-completion-output.nix b/pkgs/by-name/in/installShellFiles/tests/install-completion-output.nix new file mode 100644 index 000000000000..380b241e4f01 --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-completion-output.nix @@ -0,0 +1,27 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-completion-output" + { + outputs = [ + "out" + "bin" + ]; + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + echo foo > foo + + installShellCompletion --bash foo + + # assert it didn't go into $out + [[ ! -f $out/share/bash-completion/completions/foo ]] + + cmp foo ''${!outputBin:?}/share/bash-completion/completions/foo + + touch $out + '' diff --git a/pkgs/by-name/in/installShellFiles/tests/install-completion.nix b/pkgs/by-name/in/installShellFiles/tests/install-completion.nix new file mode 100644 index 000000000000..2738dd647f56 --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-completion.nix @@ -0,0 +1,26 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-completion" + { + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + echo foo > foo + echo bar > bar + echo baz > baz + echo qux > qux.zsh + echo quux > quux + + installShellCompletion --bash foo bar --zsh baz qux.zsh --fish quux + + cmp foo $out/share/bash-completion/completions/foo + cmp bar $out/share/bash-completion/completions/bar + cmp baz $out/share/zsh/site-functions/_baz + cmp qux.zsh $out/share/zsh/site-functions/_qux + cmp quux $out/share/fish/vendor_completions.d/quux + '' diff --git a/pkgs/by-name/in/installShellFiles/tests/install-manpage-outputs.nix b/pkgs/by-name/in/installShellFiles/tests/install-manpage-outputs.nix new file mode 100644 index 000000000000..4e249a9e5061 --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-manpage-outputs.nix @@ -0,0 +1,36 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-manpage-outputs" + { + outputs = [ + "out" + "man" + "devman" + ]; + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + mkdir -p doc + echo foo > doc/foo.1 + echo bar > doc/bar.3 + + installManPage doc/* + + # 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 ]] + + # 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 + '' diff --git a/pkgs/by-name/in/installShellFiles/tests/install-manpage.nix b/pkgs/by-name/in/installShellFiles/tests/install-manpage.nix new file mode 100644 index 000000000000..7b67d0aed94c --- /dev/null +++ b/pkgs/by-name/in/installShellFiles/tests/install-manpage.nix @@ -0,0 +1,23 @@ +{ + lib, + installShellFiles, + runCommandLocal, +}: + +runCommandLocal "install-shell-files--install-manpage" + { + nativeBuildInputs = [ installShellFiles ]; + meta.platforms = lib.platforms.all; + } + '' + mkdir -p doc + echo foo > doc/foo.1 + echo bar > doc/bar.2.gz + echo baz > doc/baz.3 + + installManPage doc/* + + cmp doc/foo.1 $out/share/man/man1/foo.1 + cmp doc/bar.2.gz $out/share/man/man2/bar.2.gz + cmp doc/baz.3 $out/share/man/man3/baz.3 + ''