aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula.rb
diff options
context:
space:
mode:
authorSamuel John2013-06-13 15:52:23 +0200
committerSamuel John2013-09-05 15:26:57 +0200
commit59a0c1e1b5604ab198e9694df030cd855b5ccbd6 (patch)
treee2d9642f20b4d0c3557877b822202402da6921fe /Library/Homebrew/formula.rb
parent6ae2e872d3154815de5137844d284a009c411d5b (diff)
downloadbrew-59a0c1e1b5604ab198e9694df030cd855b5ccbd6.tar.bz2
Improve python tests for brew bots
Allow `build.with?` and similar methods to be used during the test phase. The BuildOptions (`build`) are initialized with the `Tab.used_options` unless explicitly overwritten on the command line. So basically `build.with?` works in `def install` and in `test do` as one would naively expect. (For the test, gramatically it should be `built.with?` but who cares) If a formula was installed `--with-python`, now the tests are also run `--with-python`. This enables us to use the `python do ... end` in a meaningful manner. Using `python do ... end` blocks for the tests, because the bot.brew.sh has system python per default and we need to set the PYTHONPATH for the test. Potentially to different values for Python 2.x and 3.x.
Diffstat (limited to 'Library/Homebrew/formula.rb')
-rw-r--r--Library/Homebrew/formula.rb3
1 files changed, 3 insertions, 0 deletions
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