From 1dfeff72742fb69193d3796626ac21f368fbe64a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 14 Mar 2018 15:41:18 +0000 Subject: [PATCH] deps: don't display recursive test dependencies. You only care about the test dependencies for the specific formula you are testing right now. --- Library/Homebrew/cmd/deps.rb | 12 +++++++----- Library/Homebrew/dependency.rb | 3 +++ Library/Homebrew/test/dependency_expansion_spec.rb | 6 +++--- docs/Manpage.md | 2 +- manpages/brew.1 | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index 40aa2f413d..421edd423c 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -18,7 +18,7 @@ #: By default, `deps` shows required and recommended dependencies for #: . To include the `:build` type dependencies, pass `--include-build`. #: Similarly, pass `--include-optional` to include `:optional` dependencies or -#: `--include-test` to include `:test` dependencies. +#: `--include-test` to include (non-recursive) `:test` dependencies. #: To skip `:recommended` type dependencies, pass `--skip-recommended`. #: To include requirements in addition to dependencies, pass `--include-requirements`. #: @@ -145,8 +145,11 @@ module Homebrew if dep.recommended? Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) elsif dep.test? - next if includes.include?("test?") - Dependency.prune + 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? @@ -157,8 +160,7 @@ module Homebrew if req.recommended? Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) elsif req.test? - next if includes.include?("test?") - Requirement.prune + Requirement.prune unless includes.include?("test?") elsif req.optional? Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) elsif req.build? diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 7ae0703609..d64d46f66a 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -83,6 +83,9 @@ class Dependency deps.each do |dep| next if dependent.name == dep.name + # we only care about one level of test dependencies. + next if dep.test? && @expand_stack.length > 1 + case action(dependent, dep, &block) when :prune next diff --git a/Library/Homebrew/test/dependency_expansion_spec.rb b/Library/Homebrew/test/dependency_expansion_spec.rb index d6ecdf5527..16c37b9312 100644 --- a/Library/Homebrew/test/dependency_expansion_spec.rb +++ b/Library/Homebrew/test/dependency_expansion_spec.rb @@ -102,12 +102,12 @@ describe Dependency do end it "keeps dependency but prunes recursive dependencies with ::keep_but_prune_recursive_deps" do - foo = build_dep(:foo, [:build], bar) - baz = build_dep(:baz, [:build]) + foo = build_dep(:foo, [:test], bar) + baz = build_dep(:baz, [:test]) f = double(name: "f", deps: [foo, baz]) deps = described_class.expand(f) do |_dependent, dep| - described_class.keep_but_prune_recursive_deps if dep.build? + described_class.keep_but_prune_recursive_deps if dep.test? end expect(deps).to eq([foo, baz]) diff --git a/docs/Manpage.md b/docs/Manpage.md index 4c523c435c..0235bf86c5 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -97,7 +97,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note By default, `deps` shows required and recommended dependencies for `formulae`. To include the `:build` type dependencies, pass `--include-build`. Similarly, pass `--include-optional` to include `:optional` dependencies or - `--include-test` to include `:test` dependencies. + `--include-test` to include (non-recursive) `:test` dependencies. To skip `:recommended` type dependencies, pass `--skip-recommended`. To include requirements in addition to dependencies, pass `--include-requirements`. diff --git a/manpages/brew.1 b/manpages/brew.1 index 536049a33b..61ff665bf2 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -107,7 +107,7 @@ If \fB\-\-full\-name\fR is passed, list dependencies by their full name\. If \fB\-\-installed\fR is passed, only list those dependencies that are currently installed\. . .IP -By default, \fBdeps\fR shows required and recommended dependencies for \fIformulae\fR\. 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 or \fB\-\-include\-test\fR to include \fB:test\fR dependencies\. To skip \fB:recommended\fR type dependencies, pass \fB\-\-skip\-recommended\fR\. To include requirements in addition to dependencies, pass \fB\-\-include\-requirements\fR\. +By default, \fBdeps\fR shows required and recommended dependencies for \fIformulae\fR\. 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 or \fB\-\-include\-test\fR to include (non\-recursive) \fB:test\fR dependencies\. To skip \fB:recommended\fR type dependencies, pass \fB\-\-skip\-recommended\fR\. To include requirements in addition to dependencies, pass \fB\-\-include\-requirements\fR\. . .TP \fBdeps\fR \fB\-\-tree\fR [\fB\-\-1\fR] [\fIfilters\fR] [\fB\-\-annotate\fR] (\fIformulae\fR|\fB\-\-installed\fR)