@@ -60,9 +60,18 @@ class Foo < Formula
6060 @cmd_file . parent . mkpath
6161 touch @cmd_file
6262 chmod 0755 , @cmd_file
63- @manpage_file = @path /"man/man1 /brew-tap-cmd.1"
63+ @manpage_file = @path /"manpages /brew-tap-cmd.1"
6464 @manpage_file . parent . mkpath
6565 touch @manpage_file
66+ @bash_completion_file = @path /"completions/bash/brew-tap-cmd"
67+ @bash_completion_file . parent . mkpath
68+ touch @bash_completion_file
69+ @zsh_completion_file = @path /"completions/zsh/_brew-tap-cmd"
70+ @zsh_completion_file . parent . mkpath
71+ touch @zsh_completion_file
72+ @fish_completion_file = @path /"completions/fish/brew-tap-cmd.fish"
73+ @fish_completion_file . parent . mkpath
74+ touch @fish_completion_file
6675 end
6776
6877 def setup_git_repo
@@ -238,10 +247,39 @@ def test_install_and_uninstall
238247 shutup { tap . install clone_target : @tap . path /".git" }
239248 assert_predicate tap , :installed?
240249 assert_predicate HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" , :file?
250+ assert_predicate HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" , :file?
251+ assert_predicate HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" , :file?
252+ assert_predicate HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" , :file?
241253 shutup { tap . uninstall }
242254 refute_predicate tap , :installed?
243255 refute_predicate HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" , :exist?
244256 refute_predicate HOMEBREW_PREFIX /"share/man/man1" , :exist?
257+ refute_predicate HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" , :exist?
258+ refute_predicate HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" , :exist?
259+ refute_predicate HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" , :exist?
260+ ensure
261+ ( HOMEBREW_PREFIX /"etc" ) . rmtree if ( HOMEBREW_PREFIX /"etc" ) . exist?
262+ ( HOMEBREW_PREFIX /"share" ) . rmtree if ( HOMEBREW_PREFIX /"share" ) . exist?
263+ end
264+
265+ def test_link_completions_and_manpages
266+ setup_tap_files
267+ setup_git_repo
268+ tap = Tap . new ( "Homebrew" , "baz" )
269+ shutup { tap . install clone_target : @tap . path /".git" }
270+ ( HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" ) . delete
271+ ( HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" ) . delete
272+ ( HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" ) . delete
273+ ( HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" ) . delete
274+ shutup { tap . link_completions_and_manpages }
275+ assert_predicate HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" , :file?
276+ assert_predicate HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" , :file?
277+ assert_predicate HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" , :file?
278+ assert_predicate HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" , :file?
279+ shutup { tap . uninstall }
280+ ensure
281+ ( HOMEBREW_PREFIX /"etc" ) . rmtree if ( HOMEBREW_PREFIX /"etc" ) . exist?
282+ ( HOMEBREW_PREFIX /"share" ) . rmtree if ( HOMEBREW_PREFIX /"share" ) . exist?
245283 end
246284
247285 def test_pin_and_unpin
0 commit comments