aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorJoshua McKinney2016-09-30 18:22:53 -0500
committerJoshua McKinney2017-02-26 15:40:52 -0600
commit25396d9c4d7a7a111eebf02f0ebdbb0e69aad3b0 (patch)
treef91be666cdc54f1a69f418a7a54068509105dd23 /Library/Homebrew/test
parenta74b7ade66e340c55b3bea7b6226fa68a311b4ce (diff)
downloadbrew-25396d9c4d7a7a111eebf02f0ebdbb0e69aad3b0.tar.bz2
Install tap command completions and manpages
Taps can include completion scripts for external commands under `completions/bash`, `completions/fish`, or `completions/zsh`. `brew tap` will automatically install these into the correct directories during install.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/tap_test.rb40
1 files changed, 39 insertions, 1 deletions
diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb
index 578326cea..44bd2f88b 100644
--- a/Library/Homebrew/test/tap_test.rb
+++ b/Library/Homebrew/test/tap_test.rb
@@ -60,9 +60,18 @@ class TapTest < Homebrew::TestCase
@cmd_file.parent.mkpath
touch @cmd_file
chmod 0755, @cmd_file
- @manpage_file = @path/"man/man1/brew-tap-cmd.1"
+ @manpage_file = @path/"manpages/brew-tap-cmd.1"
@manpage_file.parent.mkpath
touch @manpage_file
+ @bash_completion_file = @path/"completions/bash/brew-tap-cmd"
+ @bash_completion_file.parent.mkpath
+ touch @bash_completion_file
+ @zsh_completion_file = @path/"completions/zsh/_brew-tap-cmd"
+ @zsh_completion_file.parent.mkpath
+ touch @zsh_completion_file
+ @fish_completion_file = @path/"completions/fish/brew-tap-cmd.fish"
+ @fish_completion_file.parent.mkpath
+ touch @fish_completion_file
end
def setup_git_repo
@@ -238,10 +247,39 @@ class TapTest < Homebrew::TestCase
shutup { tap.install clone_target: @tap.path/".git" }
assert_predicate tap, :installed?
assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file?
+ assert_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :file?
+ assert_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :file?
+ assert_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :file?
shutup { tap.uninstall }
refute_predicate tap, :installed?
refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist?
refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist?
+ refute_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :exist?
+ refute_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :exist?
+ refute_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :exist?
+ ensure
+ (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
+ (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
+ end
+
+ def test_link_completions_and_manpages
+ setup_tap_files
+ setup_git_repo
+ tap = Tap.new("Homebrew", "baz")
+ shutup { tap.install clone_target: @tap.path/".git" }
+ (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
+ (HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete
+ (HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete
+ (HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete
+ shutup { tap.link_completions_and_manpages }
+ assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file?
+ assert_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :file?
+ assert_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :file?
+ assert_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :file?
+ shutup { tap.uninstall }
+ ensure
+ (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
+ (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
end
def test_pin_and_unpin