fix brew tests

Fix the `brew tests` problem caused by core/formula separation.
This commit is contained in:
Xu Cheng 2016-02-26 19:43:49 +08:00
parent 2bb30fc5f0
commit deea4c82a4
9 changed files with 46 additions and 39 deletions

View File

@ -14,8 +14,8 @@
"stdlib": "libcxx",
"compiler": "clang",
"source": {
"path": "/usr/local/Library/Formula/foo.rb",
"tap": "Homebrew/homebrew",
"path": "/usr/local/Library/Taps/hombrew/homebrew-core/Formula/foo.rb",
"tap": "homebrew/core",
"spec": "stable"
}
}

View File

@ -7,13 +7,13 @@ update_git_diff_output_without_formulae_changes: |
M bin/brew
update_git_diff_output_with_formulae_changes: |
M Library/Contributions/brew_bash_completion.sh
A Library/Formula/antiword.rb
A Library/Formula/bash-completion.rb
A Library/Formula/ddrescue.rb
A Library/Formula/dict.rb
A Library/Formula/lua.rb
M Library/Formula/xar.rb
M Library/Formula/yajl.rb
A Formula/antiword.rb
A Formula/bash-completion.rb
A Formula/ddrescue.rb
A Formula/dict.rb
A Formula/lua.rb
M Formula/xar.rb
M Formula/yajl.rb
M Library/Homebrew/ARGV+yeast.rb
M Library/Homebrew/beer_events.rb
M Library/Homebrew/hardware.rb
@ -25,23 +25,23 @@ update_git_diff_output_with_formulae_changes: |
M README
M bin/brew
update_git_diff_output_with_removed_formulae: |
A Library/Formula/flac123.rb
M Library/Formula/gdal.rb
M Library/Formula/grass.rb
M Library/Formula/json_spirit.rb
A Library/Formula/libbson.rb
D Library/Formula/libgsasl.rb
A Formula/flac123.rb
M Formula/gdal.rb
M Formula/grass.rb
M Formula/json_spirit.rb
A Formula/libbson.rb
D Formula/libgsasl.rb
update_git_diff_output_with_changed_filetype: |
A Library/ENV/4.3/ant
T Library/ENV/4.3/bsdmake
M Library/ENV/4.3/make
M Library/Formula/elixir.rb
A Library/Formula/libbson.rb
D Library/Formula/libgsasl.rb
M Formula/elixir.rb
A Formula/libbson.rb
D Formula/libgsasl.rb
M Library/Homebrew/cmd/update.rb
M SUPPORTERS.md
update_git_diff_output_with_formula_rename: |
R100 Library/Formula/cv.rb Library/Formula/progress.rb
R100 Formula/cv.rb Formula/progress.rb
update_git_diff_output_with_restructured_tap: |
R100 git.rb Formula/git.rb
R100 lua.rb Formula/lua.rb

View File

@ -202,7 +202,7 @@ class FormulaTests < Homebrew::TestCase
def test_path
name = "foo-bar"
assert_equal Pathname.new("#{HOMEBREW_LIBRARY}/Formula/#{name}.rb"), Formulary.core_path(name)
assert_equal Pathname.new("#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/Formula/#{name}.rb"), Formulary.core_path(name)
end
def test_class_specs_are_always_initialized

View File

@ -112,7 +112,7 @@ class FormularyTapFactoryTest < Homebrew::TestCase
end
def teardown
@tap.path.parent.parent.rmtree
@tap.path.rmtree
end
def test_factory_tap_formula
@ -138,6 +138,8 @@ class FormularyTapFactoryTest < Homebrew::TestCase
another_tap = Tap.new "homebrew", "bar"
(another_tap.path/"#{@name}.rb").write @code
assert_raises(TapFormulaAmbiguityError) { Formulary.factory(@name) }
ensure
another_tap.path.rmtree
end
end
@ -158,7 +160,7 @@ class FormularyTapPriorityTest < Homebrew::TestCase
def teardown
@core_path.unlink
@tap.path.parent.parent.rmtree
@tap.path.rmtree
end
def test_find_with_priority_core_formula

View File

@ -217,7 +217,7 @@ class IntegrationCommandTests < Homebrew::TestCase
assert_match "homebrew/foo", cmd("tap")
assert_match "homebrew/versions", cmd("tap", "--list-official")
assert_match "1 tap", cmd("tap-info")
assert_match "2 taps", cmd("tap-info")
assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo")
assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed")
assert_match "Pinned homebrew/foo", cmd("tap-pin", "homebrew/foo")
@ -228,7 +228,7 @@ class IntegrationCommandTests < Homebrew::TestCase
assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full")
assert_match "Untapped", cmd("untap", "homebrew/bar")
ensure
Tap::TAP_DIRECTORY.rmtree
path.rmtree
end
def test_missing
@ -339,13 +339,12 @@ class IntegrationCommandTests < Homebrew::TestCase
end
def test_tap_readme
(HOMEBREW_LIBRARY/"Taps").mkpath
assert_match "brew install homebrew/foo/<formula>",
cmd("tap-readme", "foo", "--verbose")
readme = HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo/README.md"
assert readme.exist?, "The README should be created"
ensure
(HOMEBREW_LIBRARY/"Taps").rmtree
(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo").rmtree
end
def test_unpack

View File

@ -17,7 +17,7 @@ class TabTests < Homebrew::TestCase
"compiler" => "clang",
"stdlib" => "libcxx",
"source" => {
"tap" => "Homebrew/homebrew",
"tap" => "homebrew/core",
"path" => nil,
"spec" => "stable"
})
@ -60,7 +60,7 @@ class TabTests < Homebrew::TestCase
def test_other_attributes
assert_equal TEST_SHA1, @tab.HEAD
assert_equal "Homebrew/homebrew", @tab.tap.name
assert_equal "homebrew/core", @tab.tap.name
assert_nil @tab.time
refute_predicate @tab, :built_as_bottle
assert_predicate @tab, :poured_from_bottle
@ -74,7 +74,7 @@ class TabTests < Homebrew::TestCase
assert_equal @unused.sort, tab.unused_options.sort
refute_predicate tab, :built_as_bottle
assert_predicate tab, :poured_from_bottle
assert_equal "Homebrew/homebrew", tab.tap.name
assert_equal "homebrew/core", tab.tap.name
assert_equal :stable, tab.spec
refute_nil tab.time
assert_equal TEST_SHA1, tab.HEAD
@ -90,7 +90,7 @@ class TabTests < Homebrew::TestCase
assert_equal @unused.sort, tab.unused_options.sort
refute_predicate tab, :built_as_bottle
assert_predicate tab, :poured_from_bottle
assert_equal "Homebrew/homebrew", tab.tap.name
assert_equal "homebrew/core", tab.tap.name
assert_equal :stable, tab.spec
refute_nil tab.time
assert_equal TEST_SHA1, tab.HEAD

View File

@ -55,7 +55,7 @@ class TapTest < Homebrew::TestCase
end
def teardown
Tap::TAP_DIRECTORY.rmtree
@path.rmtree
end
def test_fetch
@ -68,7 +68,7 @@ class TapTest < Homebrew::TestCase
end
def test_names
assert_equal ["homebrew/foo"], Tap.names
assert_equal ["homebrew/core", "homebrew/foo"], Tap.names
end
def test_attributes
@ -95,6 +95,8 @@ class TapTest < Homebrew::TestCase
(Tap::TAP_DIRECTORY/"someone/homebrew-no-git").mkpath
assert_nil Tap.new("someone", "no-git").issues_url
ensure
path.parent.rmtree
end
def test_files
@ -132,6 +134,8 @@ class TapTest < Homebrew::TestCase
end
end
refute_predicate version_tap, :private?
ensure
version_tap.path.rmtree
end
def test_remote_not_git_repo
@ -213,8 +217,8 @@ class CoreTapTest < Homebrew::TestCase
def test_attributes
assert_equal "Homebrew", @repo.user
assert_equal "homebrew", @repo.repo
assert_equal "Homebrew/homebrew", @repo.name
assert_equal "core", @repo.repo
assert_equal "homebrew/core", @repo.name
assert_equal [], @repo.command_files
assert_predicate @repo, :installed?
refute_predicate @repo, :pinned?

View File

@ -29,10 +29,6 @@ class ReportTests < Homebrew::TestCase
@hub = ReporterHub.new
end
def teardown
FileUtils.rm_rf HOMEBREW_LIBRARY.join("Taps")
end
def perform_update(fixture_name = "")
Formulary.stubs(:factory).returns(stub(:pkg_version => "1.0"))
FormulaVersions.stubs(:new).returns(stub(:formula_at_revision => "2.0"))
@ -91,6 +87,8 @@ class ReportTests < Homebrew::TestCase
perform_update("update_git_diff_output_with_restructured_tap")
assert_equal %w[foo/bar/git foo/bar/lua], @hub.select_formula(:A)
assert_empty @hub.select_formula(:D)
ensure
tap.path.parent.rmtree
end
def test_update_homebrew_simulate_homebrew_php_restructuring
@ -101,6 +99,8 @@ class ReportTests < Homebrew::TestCase
perform_update("update_git_diff_simulate_homebrew_php_restructuring")
assert_empty @hub.select_formula(:A)
assert_equal %w[foo/bar/git foo/bar/lua], @hub.select_formula(:D)
ensure
tap.path.parent.rmtree
end
def test_update_homebrew_with_tap_formulae_changes
@ -112,5 +112,7 @@ class ReportTests < Homebrew::TestCase
assert_equal %w[foo/bar/lua], @hub.select_formula(:A)
assert_equal %w[foo/bar/git], @hub.select_formula(:M)
assert_empty @hub.select_formula(:D)
ensure
tap.path.parent.rmtree
end
end

View File

@ -6,7 +6,7 @@ require "global"
require "formulary"
# Test environment setup
HOMEBREW_LIBRARY.join("Formula").mkpath
(HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-core/Formula").mkpath
%w[cache formula_cache cellar logs].each { |d| HOMEBREW_PREFIX.parent.join(d).mkpath }
# Test fixtures and files can be found relative to this path