From e50c40b9c69f7e5c62c0bf2e61a4217081475cfc Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 16 Mar 2018 09:29:31 +0000 Subject: [PATCH] uses: add --include-test support. --- Library/Homebrew/cmd/uses.rb | 23 +++++++++++++++++++---- docs/Manpage.md | 10 ++++++---- manpages/brew.1 | 6 +++--- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index d5c9210f6b..4693a5b8d5 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -1,4 +1,4 @@ -#: * `uses` [`--installed`] [`--recursive`] [`--include-build`] [`--include-optional`] [`--skip-recommended`] [`--devel`|`--HEAD`] : +#: * `uses` [`--installed`] [`--recursive`] [`--include-build`] [`--include-test`] [`--include-optional`] [`--skip-recommended`] [`--devel`|`--HEAD`] : #: Show the formulae that specify as a dependency. When given #: multiple formula arguments, show the intersection of formulae that use #: . @@ -9,10 +9,12 @@ #: #: By default, `uses` shows all formulae that specify as a required #: or recommended dependency. To include the `:build` type dependencies, pass -#: `--include-build`. Similarly, pass `--include-optional` to include `:optional` -#: dependencies. To skip `:recommended` type dependencies, pass `--skip-recommended`. +#: `--include-build`, to include the `:test` type dependencies, pass +#: `--include-test` and to include `:optional` dependencies pass +#: `--include-optional`. To skip `:recommended` type dependencies, pass +#: `--skip-recommended`. #: -#: By default, `uses` shows usages of by stable builds. To find +#: By default, `uses` shows usage of by stable builds. To find #: cases where is used by development or HEAD build, pass #: `--devel` or `--HEAD`. @@ -47,6 +49,11 @@ module Homebrew else ignores << "build?" end + if ARGV.include? "--include-test" + includes << "test?" + else + ignores << "test?" + end if ARGV.include? "--include-optional" includes << "optional?" else @@ -61,6 +68,12 @@ module Homebrew deps = f.recursive_dependencies do |dependent, dep| if dep.recommended? Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.test? + if includes.include?("test?") + Dependency.keep_but_prune_recursive_deps + else + Dependency.prune + end elsif dep.optional? Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) elsif dep.build? @@ -89,6 +102,8 @@ module Homebrew reqs_by_formula.reject! do |dependent, req| if req.recommended? ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.test? + Requirement.prune unless includes.include?("test?") elsif req.optional? !includes.include?("optional?") && !dependent.build.with?(req) elsif req.build? diff --git a/docs/Manpage.md b/docs/Manpage.md index 0235bf86c5..be6947f4f8 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -565,7 +565,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note If `formulae` are given, upgrade only the specified brews (unless they are pinned; see `pin`, `unpin`). - * `uses` [`--installed`] [`--recursive`] [`--include-build`] [`--include-optional`] [`--skip-recommended`] [`--devel`|`--HEAD`] `formulae`: + * `uses` [`--installed`] [`--recursive`] [`--include-build`] [`--include-test`] [`--include-optional`] [`--skip-recommended`] [`--devel`|`--HEAD`] `formulae`: Show the formulae that specify `formulae` as a dependency. When given multiple formula arguments, show the intersection of formulae that use `formulae`. @@ -576,10 +576,12 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note By default, `uses` shows all formulae that specify `formulae` as a required or recommended dependency. To include the `:build` type dependencies, pass - `--include-build`. Similarly, pass `--include-optional` to include `:optional` - dependencies. To skip `:recommended` type dependencies, pass `--skip-recommended`. + `--include-build`, to include the `:test` type dependencies, pass + `--include-test` and to include `:optional` dependencies pass + `--include-optional`. To skip `:recommended` type dependencies, pass + `--skip-recommended`. - By default, `uses` shows usages of `formulae` by stable builds. To find + By default, `uses` shows usage of `formulae` by stable builds. To find cases where `formulae` is used by development or HEAD build, pass `--devel` or `--HEAD`. diff --git a/manpages/brew.1 b/manpages/brew.1 index 61ff665bf2..1f889843ea 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -579,7 +579,7 @@ If \fB\-\-fetch\-HEAD\fR is passed, fetch the upstream repository to detect if t If \fIformulae\fR are given, upgrade only the specified brews (unless they are pinned; see \fBpin\fR, \fBunpin\fR)\. . .TP -\fBuses\fR [\fB\-\-installed\fR] [\fB\-\-recursive\fR] [\fB\-\-include\-build\fR] [\fB\-\-include\-optional\fR] [\fB\-\-skip\-recommended\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] \fIformulae\fR +\fBuses\fR [\fB\-\-installed\fR] [\fB\-\-recursive\fR] [\fB\-\-include\-build\fR] [\fB\-\-include\-test\fR] [\fB\-\-include\-optional\fR] [\fB\-\-skip\-recommended\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] \fIformulae\fR Show the formulae that specify \fIformulae\fR as a dependency\. When given multiple formula arguments, show the intersection of formulae that use \fIformulae\fR\. . .IP @@ -589,10 +589,10 @@ Use \fB\-\-recursive\fR to resolve more than one level of dependencies\. If \fB\-\-installed\fR is passed, only list installed formulae\. . .IP -By default, \fBuses\fR shows all formulae that specify \fIformulae\fR as a required or recommended dependency\. To include the \fB:build\fR type dependencies, pass \fB\-\-include\-build\fR\. Similarly, pass \fB\-\-include\-optional\fR to include \fB:optional\fR dependencies\. To skip \fB:recommended\fR type dependencies, pass \fB\-\-skip\-recommended\fR\. +By default, \fBuses\fR shows all formulae that specify \fIformulae\fR as a required or recommended dependency\. To include the \fB:build\fR type dependencies, pass \fB\-\-include\-build\fR, to include the \fB:test\fR type dependencies, pass \fB\-\-include\-test\fR and to include \fB:optional\fR dependencies pass \fB\-\-include\-optional\fR\. To skip \fB:recommended\fR type dependencies, pass \fB\-\-skip\-recommended\fR\. . .IP -By default, \fBuses\fR shows usages of \fIformulae\fR by stable builds\. To find cases where \fIformulae\fR is used by development or HEAD build, pass \fB\-\-devel\fR or \fB\-\-HEAD\fR\. +By default, \fBuses\fR shows usage of \fIformulae\fR by stable builds\. To find cases where \fIformulae\fR is used by development or HEAD build, pass \fB\-\-devel\fR or \fB\-\-HEAD\fR\. . .TP \fB\-\-cache\fR