brew/Library/Homebrew/test/test_build_options.rb
Jack Nagel fd86e6d636 Remove confusing implicit options handling
This code is supposed to allow

  depends_on "foo" => "with-bar"

to work when foo has only a "without-bar" option.

The options system was not designed to support this. Unfortunately, it
was bolted on anyway. The implementation is extremely difficult to
understand, and it only works for certain types of options, which is
confusing from a user's point of view. Luckily, no formulae in core or
the official taps rely on the behavior in order to function.

It is hindering progress in improving this code, so I am removing it.
2014-07-30 21:46:22 -05:00

58 lines
1.3 KiB
Ruby

require 'testing_env'
require 'build_options'
class BuildOptionsTests < Homebrew::TestCase
def setup
args = %w{--with-foo --with-bar --without-qux}
@build = BuildOptions.new(args)
@build.add("with-foo")
@build.add("with-bar")
@build.add("without-baz")
@build.add("without-qux")
end
def test_as_flags
assert_equal %w{--with-foo --with-bar --without-baz --without-qux}.sort,
@build.as_flags.sort
end
def test_has_option?
assert @build.has_option?("with-foo")
assert !@build.has_option?("with-qux")
end
def test_include
assert_includes @build, "with-foo"
refute_includes @build, "with-qux"
refute_includes @build, "--with-foo"
end
def test_with_without
assert @build.with?("foo")
assert @build.with?("bar")
assert @build.with?("baz")
assert @build.without?("qux")
end
def test_used_options
assert_includes @build.used_options, "--with-foo"
assert_includes @build.used_options, "--with-bar"
end
def test_unused_options
assert_includes @build.unused_options, "--without-baz"
end
def test_copies_do_not_share_underlying_options
orig = BuildOptions.new []
copy = orig.dup
refute_same orig.args, copy.args
end
def test_copies_do_not_share_underlying_args
orig = BuildOptions.new []
copy = orig.dup
refute_same orig.args, copy.args
end
end