mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

The array of options that is passed to the spawned build process is a combination of the current ARGV, options passed in by a dependent formula, and an existing install receipt. The objects that are interacting here each expect the resulting collection to have certain properties, and the expectations are not consistent. Clear up this confusing mess by only dealing with Options collections. This keeps our representation of options uniform across the codebase. We can remove BuildOptions dependency on HomebrewArgvExtension, which allows us to pass any Array-like collection to Tab.create. The only other site inside of FormulaInstaller that uses the array is the #exec call, and there it is splatted and thus we can substitute our Options collection there as well.
46 lines
1.1 KiB
Ruby
46 lines
1.1 KiB
Ruby
require 'testing_env'
|
|
require 'build_options'
|
|
|
|
class BuildOptionsTests < Test::Unit::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 @build.include?("with-foo")
|
|
assert !@build.include?("with-qux")
|
|
assert !@build.include?("--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 @build.used_options.include?("--with-foo")
|
|
assert @build.used_options.include?("--with-bar")
|
|
end
|
|
|
|
def test_unused_options
|
|
assert @build.unused_options.include?("--without-baz")
|
|
end
|
|
end
|