From 82e82b7fbcbefd7747218a65f4dfbabaecf3bafb Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 15 Mar 2018 13:37:34 +0000 Subject: [PATCH] install: add --include-test option. Allow at `install` (or `install --only-dependencies`) time to specify that test dependencies should be installed. This will allow simplifying code in `brew test-bot`. This could also be made an environment variable if desired by maintainers. --- Library/Homebrew/cmd/install.rb | 5 ++++- Library/Homebrew/extend/ARGV.rb | 1 + Library/Homebrew/formula_installer.rb | 7 ++++++- docs/Manpage.md | 5 ++++- manpages/brew.1 | 5 ++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index ac4810c8cd..94ae10f420 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -1,4 +1,4 @@ -#: * `install` [`--debug`] [`--env=`(`std`|`super`)] [`--ignore-dependencies`|`--only-dependencies`] [`--cc=`] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] [`--keep-tmp`] [`--build-bottle`] [`--force`] [`--verbose`] [ ...]: +#: * `install` [`--debug`] [`--env=`(`std`|`super`)] [`--ignore-dependencies`|`--only-dependencies`] [`--cc=`] [`--build-from-source`|`--force-bottle`] [`--include-test`] [`--devel`|`--HEAD`] [`--keep-tmp`] [`--build-bottle`] [`--force`] [`--verbose`] [ ...]: #: Install . #: #: is usually the name of the formula to install, but it can be specified @@ -36,6 +36,9 @@ #: current or newest version of macOS, even if it would not normally be used #: for installation. #: +#: If `--include-test` is passed, install testing dependencies. These are only +#: needed by formulae maintainers to run `brew test`. +#: #: If `--devel` is passed, and defines it, install the development version. #: #: If `--HEAD` is passed, and defines it, install the HEAD version, diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 2bc84620a4..8f8a63c7ef 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -15,6 +15,7 @@ module HomebrewArgvExtension --no-sandbox --build-bottle --force-bottle + --include-test --verbose --force -i diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index adcc596771..b0dc0eb232 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -34,7 +34,7 @@ class FormulaInstaller attr_accessor :options, :build_bottle, :invalid_option_names attr_accessor :installed_as_dependency, :installed_on_request, :link_keg mode_attr_accessor :show_summary_heading, :show_header - mode_attr_accessor :build_from_source, :force_bottle + mode_attr_accessor :build_from_source, :force_bottle, :include_test mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git mode_attr_accessor :verbose, :debug, :quieter @@ -47,6 +47,7 @@ class FormulaInstaller @build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? @build_bottle = false @force_bottle = ARGV.force_bottle? + @include_test = ARGV.include?("--include-test") @interactive = false @git = false @verbose = ARGV.verbose? @@ -442,6 +443,8 @@ class FormulaInstaller Requirement.prune elsif req.satisfied? Requirement.prune + elsif include_test? && req.test? + next elsif !runtime_requirements.include?(req) && install_bottle_for_dependent Requirement.prune else @@ -468,6 +471,8 @@ class FormulaInstaller if (dep.optional? || dep.recommended?) && build.without?(dep) Dependency.prune + elsif include_test? && dep.test? && !dep.installed? + Dependency.keep_but_prune_recursive_deps elsif dep.build? && install_bottle_for?(dependent, build) Dependency.prune elsif dep.build? && dependent.installed? diff --git a/docs/Manpage.md b/docs/Manpage.md index 4c523c435c..6c6a665a61 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -216,7 +216,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note See the docs for examples of using the JSON output: - * `install` [`--debug`] [`--env=`(`std`|`super`)] [`--ignore-dependencies`|`--only-dependencies`] [`--cc=``compiler`] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] [`--keep-tmp`] [`--build-bottle`] [`--force`] [`--verbose`] `formula` [`options` ...]: + * `install` [`--debug`] [`--env=`(`std`|`super`)] [`--ignore-dependencies`|`--only-dependencies`] [`--cc=``compiler`] [`--build-from-source`|`--force-bottle`] [`--include-test`] [`--devel`|`--HEAD`] [`--keep-tmp`] [`--build-bottle`] [`--force`] [`--verbose`] `formula` [`options` ...]: Install `formula`. `formula` is usually the name of the formula to install, but it can be specified @@ -254,6 +254,9 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note current or newest version of macOS, even if it would not normally be used for installation. + If `--include-test` is passed, install testing dependencies. These are only + needed by formulae maintainers to run `brew test`. + If `--devel` is passed, and `formula` defines it, install the development version. If `--HEAD` is passed, and `formula` defines it, install the HEAD version, diff --git a/manpages/brew.1 b/manpages/brew.1 index 536049a33b..35695e3f17 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -229,7 +229,7 @@ Pass \fB\-\-all\fR to get information on all formulae, or \fB\-\-installed\fR to See the docs for examples of using the JSON output: \fIhttps://docs\.brew\.sh/Querying\-Brew\fR . .TP -\fBinstall\fR [\fB\-\-debug\fR] [\fB\-\-env=\fR(\fBstd\fR|\fBsuper\fR)] [\fB\-\-ignore\-dependencies\fR|\fB\-\-only\-dependencies\fR] [\fB\-\-cc=\fR\fIcompiler\fR] [\fB\-\-build\-from\-source\fR|\fB\-\-force\-bottle\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-keep\-tmp\fR] [\fB\-\-build\-bottle\fR] [\fB\-\-force\fR] [\fB\-\-verbose\fR] \fIformula\fR [\fIoptions\fR \.\.\.] +\fBinstall\fR [\fB\-\-debug\fR] [\fB\-\-env=\fR(\fBstd\fR|\fBsuper\fR)] [\fB\-\-ignore\-dependencies\fR|\fB\-\-only\-dependencies\fR] [\fB\-\-cc=\fR\fIcompiler\fR] [\fB\-\-build\-from\-source\fR|\fB\-\-force\-bottle\fR] [\fB\-\-include\-test\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-keep\-tmp\fR] [\fB\-\-build\-bottle\fR] [\fB\-\-force\fR] [\fB\-\-verbose\fR] \fIformula\fR [\fIoptions\fR \.\.\.] Install \fIformula\fR\. . .IP @@ -263,6 +263,9 @@ If \fBHOMEBREW_BUILD_FROM_SOURCE\fR is set, regardless of whether \fB\-\-build\- If \fB\-\-force\-bottle\fR is passed, install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation\. . .IP +If \fB\-\-include\-test\fR is passed, install testing dependencies\. These are only needed by formulae maintainers to run \fBbrew test\fR\. +. +.IP If \fB\-\-devel\fR is passed, and \fIformula\fR defines it, install the development version\. . .IP