diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Formula/enchant.rb | 14 | ||||
| -rw-r--r-- | Library/Formula/fontforge.rb | 8 | ||||
| -rw-r--r-- | Library/Formula/libvirt.rb | 10 | ||||
| -rw-r--r-- | Library/Formula/libxml2.rb | 5 | ||||
| -rw-r--r-- | Library/Formula/omniorb.rb | 3 | ||||
| -rw-r--r-- | Library/Formula/portmidi.rb | 4 | ||||
| -rw-r--r-- | Library/Formula/pygtkglext.rb | 4 | ||||
| -rw-r--r-- | Library/Formula/pygtksourceview.rb | 4 | ||||
| -rw-r--r-- | Library/Formula/shiboken.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/build_options.rb | 25 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/python_helper.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_build_options.rb | 20 |
13 files changed, 66 insertions, 46 deletions
diff --git a/Library/Formula/enchant.rb b/Library/Formula/enchant.rb index 2d331c8e0..2a99f0571 100644 --- a/Library/Formula/enchant.rb +++ b/Library/Formula/enchant.rb @@ -21,28 +21,24 @@ class Enchant < Formula "--prefix=#{prefix}", "--disable-ispell", "--disable-myspell" - system "make install" + system "make", "install" - if build.with? 'python' + python do # Now we handle the python bindings from the subformulae PyEnchant PyEnchant.new.brew do # Don't download and install distribute now inreplace 'setup.py', "distribute_setup.use_setuptools()", "" - python do ENV['PYENCHANT_LIBRARY_PATH'] = lib/'libenchant.dylib' system python, 'setup.py', 'install', "--prefix=#{prefix}", '--single-version-externally-managed', '--record=installed.txt' - end end end end - def test - if build.with? 'python' - python do - system python, "-c", "import enchant; d=enchant.Dict('en_US'); print(d.suggest('homebrew'))" - end + test do + python do + system python, "-c", "import enchant; d=enchant.Dict('en_US'); print(d.suggest('homebrew'))" end end end diff --git a/Library/Formula/fontforge.rb b/Library/Formula/fontforge.rb index bb8d9b7fe..dbe0688fe 100644 --- a/Library/Formula/fontforge.rb +++ b/Library/Formula/fontforge.rb @@ -85,12 +85,10 @@ class Fontforge < Formula system "make install" end - def test + test do system "#{bin}/fontforge", "-version" - if build.with? 'python' - python do - system python, "-c", "import fontforge" - end + python do + system python, "-c", "import fontforge" end end diff --git a/Library/Formula/libvirt.rb b/Library/Formula/libvirt.rb index 6b88d28a2..f47bb0b7e 100644 --- a/Library/Formula/libvirt.rb +++ b/Library/Formula/libvirt.rb @@ -63,12 +63,10 @@ class Libvirt < Formula end test do - if build.with? 'python' - python do - # Testing to import the mod because that is a .so file where linking - # can break. - system python, '-c', "import libvirtmod" - end + python do + # Testing to import the mod because that is a .so file where linking + # can break. + system python, '-c', "import libvirtmod" end end end diff --git a/Library/Formula/libxml2.rb b/Library/Formula/libxml2.rb index ff762f22e..f78d0a1c0 100644 --- a/Library/Formula/libxml2.rb +++ b/Library/Formula/libxml2.rb @@ -75,11 +75,8 @@ class Libxml2 < Formula end test do - if build.with? 'python' + python do system python, '-c', "import libxml2" - else - puts "No tests because built --without-python." - true end end end diff --git a/Library/Formula/omniorb.rb b/Library/Formula/omniorb.rb index 813da8ec3..a9b2a196e 100644 --- a/Library/Formula/omniorb.rb +++ b/Library/Formula/omniorb.rb @@ -38,8 +38,7 @@ class Omniorb < Formula test do system "#{bin}/omniidl", "-h" - - if build.with? 'python' + python do system python, "-c", %(import omniORB; print 'omniORBpy', omniORB.__version__) end end diff --git a/Library/Formula/portmidi.rb b/Library/Formula/portmidi.rb index d24661f06..ccecfd766 100644 --- a/Library/Formula/portmidi.rb +++ b/Library/Formula/portmidi.rb @@ -43,8 +43,8 @@ class Portmidi < Formula end test do - if build.with?('python') || Tab.for_name('portmidi').with?('python') - system "python", "-c", "import pyportmidi; pyportmidi.init()" + python do + system python, "-c", "import pyportmidi; pyportmidi.init()" end end diff --git a/Library/Formula/pygtkglext.rb b/Library/Formula/pygtkglext.rb index 92e583bf8..326af30da 100644 --- a/Library/Formula/pygtkglext.rb +++ b/Library/Formula/pygtkglext.rb @@ -23,6 +23,8 @@ class Pygtkglext < Formula end test do - system "python", "-c", "import pygtk", "pygtk.require('2.0')", "import gtk.gtkgl" + python do + system python, "-c", "import pygtk", "pygtk.require('2.0')", "import gtk.gtkgl" + end end end diff --git a/Library/Formula/pygtksourceview.rb b/Library/Formula/pygtksourceview.rb index 485df897f..fe8de6245 100644 --- a/Library/Formula/pygtksourceview.rb +++ b/Library/Formula/pygtksourceview.rb @@ -22,6 +22,8 @@ class Pygtksourceview < Formula end test do - system "python", "-c", "import gtksourceview2" + python do + system python, "-c", "import gtksourceview2" + end end end diff --git a/Library/Formula/shiboken.rb b/Library/Formula/shiboken.rb index fe01e19b9..171a666a2 100644 --- a/Library/Formula/shiboken.rb +++ b/Library/Formula/shiboken.rb @@ -49,10 +49,8 @@ class Shiboken < Formula end test do - if build.with? 'python' - python do - system python, "-c", "import shiboken" - end + python do + system python, "-c", "import shiboken" end end end diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb index 0cd3a5a46..441a81bc2 100644 --- a/Library/Homebrew/build_options.rb +++ b/Library/Homebrew/build_options.rb @@ -100,13 +100,26 @@ class BuildOptions # implicit_options are needed because `depends_on 'spam' => 'with-stuff'` # complains if 'spam' has stuff as default and only defines `--without-stuff`. def implicit_options - implicit = unused_options.map do |o| - if o.name =~ /^with-(.+)$/ && without?($1) - Option.new("without-#{$1}") # we lose the description, but that's ok - elsif o.name =~ /^without-(.+)$/ && with?($1) - Option.new("with-#{$1}") - end + implicit = unused_options.map do |option| + opposite_of option unless has_opposite_of? option end.compact Options.new(implicit) end + + def has_opposite_of? option + true if args.include? opposite_of option + end + + def opposite_of option + option = Option.new option + if option.name =~ /^with-(.+)$/ + Option.new("without-#{$1}") + elsif option.name =~ /^without-(.+)$/ + Option.new("with-#{$1}") + elsif option.name =~ /^enable-(.+)$/ + Option.new("disable-#{$1}") + elsif option.name =~ /^disable-(.+)$/ + Option.new("enable-#{$1}") + end + end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 39bea8ee6..e5b071c0f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -515,6 +515,9 @@ class Formula def test require 'test/unit/assertions' extend(Test::Unit::Assertions) + # Adding the used options allows us to use `build.with?` inside of tests + tab = Tab.for_name(name) + tab.used_options.each { |opt| build.args << opt unless build.has_opposite_of? opt } ret = nil mktemp do @testpath = Pathname.pwd diff --git a/Library/Homebrew/python_helper.rb b/Library/Homebrew/python_helper.rb index 8ebf0b794..bace441fc 100644 --- a/Library/Homebrew/python_helper.rb +++ b/Library/Homebrew/python_helper.rb @@ -16,11 +16,11 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block) if !block_given? and !@current_python.nil? # We are already inside of a `python do ... end` block, so just return - # the current_python or false if the version.major is not allowed. + # the current_python or nil if the version.major is not allowed. if options[:allowed_major_versions].include?(@current_python.version.major) return @current_python else - return false + return nil end end @@ -42,7 +42,7 @@ def python_helper(options={:allowed_major_versions => [2, 3]}, &block) end # Allow to use an else-branch like so: `if python do ... end; else ... end`. - return false if filtered_python_reqs.empty? + return nil if filtered_python_reqs.empty? # Sort by version, so the older 2.x will be used first and if no # block_given? then 2.x is preferred because it is returned. diff --git a/Library/Homebrew/test/test_build_options.rb b/Library/Homebrew/test/test_build_options.rb index cc5fd01d7..9e2a9e06f 100644 --- a/Library/Homebrew/test/test_build_options.rb +++ b/Library/Homebrew/test/test_build_options.rb @@ -1,9 +1,9 @@ -require 'testing_env' + require 'testing_env' require 'build_options' class BuildOptionsTests < Test::Unit::TestCase def setup - args = %w{--with-foo --with-bar --without-qux} + args = %w{--with-foo --with-bar --without-qux} # args fake the command line @build = BuildOptions.new(args) @build.add("with-foo") @build.add("with-bar") @@ -44,7 +44,7 @@ class BuildOptionsTests < Test::Unit::TestCase end def test_implicit_options - # --without-baz is not explicitly specified on the command line + # --without-baz is not explicitly specified on the command line (i.e. args) # therefore --with-baz should be implicitly assumed: assert @build.implicit_options.include?("--with-baz") # But all these should not be in the implict_options: @@ -53,4 +53,18 @@ class BuildOptionsTests < Test::Unit::TestCase assert !@build.implicit_options.include?("--without-bar") assert !@build.implicit_options.include?("--with-qux") end + + def test_opposite_of + assert @build.opposite_of(Option.new("with-foo")) == Option.new("without-foo") + assert @build.opposite_of("without-foo") == Option.new("with-foo") + assert @build.opposite_of(Option.new("enable-spam")) == Option.new("disable-spam") + assert @build.opposite_of("disable-beer") == Option.new("enable-beer") + end + + def test_has_opposite_of? + assert @build.has_opposite_of?("--without-foo") + assert @build.has_opposite_of?(Option.new("--with-qux")) + assert !@build.has_opposite_of?("--without-qux") + assert !@build.has_opposite_of?("--without-nonexisting") + end end |
