1 { lib, runCommandLocal, recurseIntoAttrs, installShellFiles }:
4 runTest = name: env: buildCommand:
5 runCommandLocal "install-shell-files--${name}" ({
6 nativeBuildInputs = [ installShellFiles ];
7 meta.platforms = lib.platforms.all;
8 } // env) buildCommand;
14 install-manpage = runTest "install-manpage" {} ''
17 echo bar > doc/bar.2.gz
22 cmp doc/foo.1 $out/share/man/man1/foo.1
23 cmp doc/bar.2.gz $out/share/man/man2/bar.2.gz
24 cmp doc/baz.3 $out/share/man/man3/baz.3
26 install-manpage-outputs = runTest "install-manpage-outputs" {
27 outputs = [ "out" "man" "devman" ];
35 # assert they didn't go into $out
36 [[ ! -f $out/share/man/man1/foo.1 && ! -f $out/share/man/man3/bar.3 ]]
38 # foo.1 alone went into man
39 cmp doc/foo.1 ''${!outputMan:?}/share/man/man1/foo.1
40 [[ ! -f ''${!outputMan:?}/share/man/man3/bar.3 ]]
42 # bar.3 alone went into devman
43 cmp doc/bar.3 ''${!outputDevman:?}/share/man/man3/bar.3
44 [[ ! -f ''${!outputDevman:?}/share/man/man1/foo.1 ]]
49 # installShellCompletion
51 install-completion = runTest "install-completion" {} ''
58 installShellCompletion --bash foo bar --zsh baz qux.zsh --fish quux
60 cmp foo $out/share/bash-completion/completions/foo
61 cmp bar $out/share/bash-completion/completions/bar
62 cmp baz $out/share/zsh/site-functions/_baz
63 cmp qux.zsh $out/share/zsh/site-functions/_qux
64 cmp quux $out/share/fish/vendor_completions.d/quux
66 install-completion-output = runTest "install-completion-output" {
67 outputs = [ "out" "bin" ];
71 installShellCompletion --bash foo
73 # assert it didn't go into $out
74 [[ ! -f $out/share/bash-completion/completions/foo ]]
76 cmp foo ''${!outputBin:?}/share/bash-completion/completions/foo
80 install-completion-name = runTest "install-completion-name" {} ''
85 installShellCompletion --bash --name foobar.bash foo --zsh --name _foobar bar --fish baz
87 cmp foo $out/share/bash-completion/completions/foobar.bash
88 cmp bar $out/share/zsh/site-functions/_foobar
89 cmp baz $out/share/fish/vendor_completions.d/baz
91 install-completion-inference = runTest "install-completion-inference" {} ''
96 installShellCompletion foo.bash bar.zsh baz.fish
98 cmp foo.bash $out/share/bash-completion/completions/foo.bash
99 cmp bar.zsh $out/share/zsh/site-functions/_bar
100 cmp baz.fish $out/share/fish/vendor_completions.d/baz.fish
102 install-completion-cmd = runTest "install-completion-cmd" {} ''
108 installShellCompletion --cmd foobar --bash foo.bash --zsh bar.zsh --fish baz.fish --name qux qux.fish
110 cmp foo.bash $out/share/bash-completion/completions/foobar.bash
111 cmp bar.zsh $out/share/zsh/site-functions/_foobar
112 cmp baz.fish $out/share/fish/vendor_completions.d/foobar.fish
113 cmp qux.fish $out/share/fish/vendor_completions.d/qux
115 install-completion-fifo = runTest "install-completion-fifo" {} ''
116 installShellCompletion \
117 --bash --name foo.bash <(echo foo) \
118 --zsh --name _foo <(echo bar) \
119 --fish --name foo.fish <(echo baz)
121 [[ $(<$out/share/bash-completion/completions/foo.bash) == foo ]] || { echo "foo.bash comparison failed"; exit 1; }
122 [[ $(<$out/share/zsh/site-functions/_foo) == bar ]] || { echo "_foo comparison failed"; exit 1; }
123 [[ $(<$out/share/fish/vendor_completions.d/foo.fish) == baz ]] || { echo "foo.fish comparison failed"; exit 1; }