Skip to content
Snippets Groups Projects
Commit 62e14ea6 authored by Bruce Steedman's avatar Bruce Steedman
Browse files

invalid build options - fixed conflicts; rename

parent 1e1903e4
No related branches found
No related tags found
No related merge requests found
......@@ -101,6 +101,15 @@ class BuildOptions
@options - @args
end
# @private
def invalid_options
@args - @options
end
def invalid_option_names
invalid_options.map(&:flag).sort
end
private
def option_defined?(name)
......
......@@ -261,7 +261,9 @@ module Homebrew
f.print_tap_action
fi = FormulaInstaller.new(f)
fi.options = f.build.used_options
build_options = f.build
fi.options = build_options.used_options
fi.invalid_opt_names = build_options.invalid_option_names
fi.ignore_deps = ARGV.ignore_deps?
fi.only_deps = ARGV.only_deps?
fi.build_bottle = ARGV.build_bottle?
......
......@@ -32,7 +32,7 @@ class FormulaInstaller
end
attr_reader :formula
attr_accessor :options, :build_bottle
attr_accessor :options, :build_bottle, :invalid_opt_names
mode_attr_accessor :show_summary_heading, :show_header
mode_attr_accessor :build_from_source, :force_bottle
mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git
......@@ -52,6 +52,7 @@ class FormulaInstaller
@quieter = false
@debug = false
@options = Options.new
@invalid_opt_names = []
@@attempted ||= Set.new
......@@ -214,6 +215,10 @@ class FormulaInstaller
opoo "#{formula.full_name}: #{old_flag} was deprecated; using #{new_flag} instead!"
end
invalid_opt_names.each do |option|
opoo "#{formula.full_name}: #{option} is invalid for this formula and will be ignored!"
end
oh1 "Installing #{Formatter.identifier(formula.full_name)}" if show_header?
if formula.tap && !formula.tap.private?
......
......@@ -7,6 +7,8 @@ class BuildOptionsTests < Homebrew::TestCase
args = Options.create(%w[--with-foo --with-bar --without-qux])
opts = Options.create(%w[--with-foo --with-bar --without-baz --without-qux])
@build = BuildOptions.new(args, opts)
bad_args = Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc])
@bad_build = BuildOptions.new(bad_args, opts)
end
def test_include
......@@ -31,4 +33,17 @@ class BuildOptionsTests < Homebrew::TestCase
def test_unused_options
assert_includes @build.unused_options, "--without-baz"
end
def test_invalid_options
assert_empty @build.invalid_options
assert_includes @bad_build.invalid_options, "--without-bas"
assert_includes @bad_build.invalid_options, "--without-abc"
refute_includes @bad_build.invalid_options, "--with-foo"
refute_includes @bad_build.invalid_options, "--with-baz"
end
def test_invalid_opt_names
assert_empty @build.invalid_opt_names
assert_equal @bad_build.invalid_opt_names, %w[--without-abc --without-bas]
end
end
......@@ -37,6 +37,7 @@ class InstallTests < Homebrew::TestCase
end
def test_a_basic_install
ARGV << "--with-invalid_flag" # added to ensure it doesn't fail install
temporary_install(Testball.new) do |f|
# Test that things made it into the Keg
assert_predicate f.prefix+"readme", :exist?
......
......@@ -21,4 +21,10 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase
assert_match "testball1 already installed, it's just not migrated",
cmd("install", "testball2")
end
def test_install_with_invalid_option
setup_test_formula "testball1"
assert_match "testball1: --with-fo is invalid for this formula and will be ignored!",
cmd("install", "testball1", "--with-fo")
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment