aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
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/test
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/test')
-rw-r--r--Library/Homebrew/test/test_build_options.rb20
1 files changed, 17 insertions, 3 deletions
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