From 59a0c1e1b5604ab198e9694df030cd855b5ccbd6 Mon Sep 17 00:00:00 2001 From: Samuel John Date: Thu, 13 Jun 2013 15:52:23 +0200 Subject: 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. --- Library/Homebrew/python_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/python_helper.rb') 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. -- cgit v1.2.3