Fix the update tests
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
parent
5f4871ba9d
commit
4da905b7fb
@ -23,6 +23,8 @@ class RefreshBrewMock < RefreshBrew
|
|||||||
raise "#{inspect} Unexpectedly called backticks in pwd `#{HOMEBREW_PREFIX}' and command `#{cmd}'"
|
raise "#{inspect} Unexpectedly called backticks in pwd `#{HOMEBREW_PREFIX}' and command `#{cmd}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias safe_system `
|
||||||
|
|
||||||
def expectations_met?
|
def expectations_met?
|
||||||
@expect.keys.sort == @called.sort
|
@expect.keys.sort == @called.sort
|
||||||
@ -54,8 +56,8 @@ class UpdaterTests < Test::Unit::TestCase
|
|||||||
def test_update_homebrew_without_any_changes
|
def test_update_homebrew_without_any_changes
|
||||||
outside_prefix do
|
outside_prefix do
|
||||||
updater = RefreshBrewMock.new
|
updater = RefreshBrewMock.new
|
||||||
updater.in_prefix_expect("git checkout master")
|
updater.in_prefix_expect(RefreshBrew::INIT_COMMAND)
|
||||||
updater.in_prefix_expect("git pull origin master", "Already up-to-date.\n")
|
updater.in_prefix_expect(RefreshBrew::UPDATE_COMMAND, "Already up-to-date.\n")
|
||||||
|
|
||||||
assert_equal false, updater.update_from_masterbrew!
|
assert_equal false, updater.update_from_masterbrew!
|
||||||
assert updater.expectations_met?
|
assert updater.expectations_met?
|
||||||
@ -67,9 +69,9 @@ class UpdaterTests < Test::Unit::TestCase
|
|||||||
def test_update_homebrew_without_formulae_changes
|
def test_update_homebrew_without_formulae_changes
|
||||||
outside_prefix do
|
outside_prefix do
|
||||||
updater = RefreshBrewMock.new
|
updater = RefreshBrewMock.new
|
||||||
updater.in_prefix_expect("git checkout master")
|
updater.in_prefix_expect(RefreshBrew::INIT_COMMAND)
|
||||||
output = fixture('update_git_pull_output_without_formulae_changes')
|
output = fixture('update_git_pull_output_without_formulae_changes')
|
||||||
updater.in_prefix_expect("git pull origin master", output)
|
updater.in_prefix_expect(RefreshBrew::UPDATE_COMMAND, output)
|
||||||
|
|
||||||
assert_equal true, updater.update_from_masterbrew!
|
assert_equal true, updater.update_from_masterbrew!
|
||||||
assert !updater.pending_formulae_changes?
|
assert !updater.pending_formulae_changes?
|
||||||
@ -81,9 +83,9 @@ class UpdaterTests < Test::Unit::TestCase
|
|||||||
def test_update_homebrew_with_formulae_changes
|
def test_update_homebrew_with_formulae_changes
|
||||||
outside_prefix do
|
outside_prefix do
|
||||||
updater = RefreshBrewMock.new
|
updater = RefreshBrewMock.new
|
||||||
updater.in_prefix_expect("git checkout master")
|
updater.in_prefix_expect(RefreshBrew::INIT_COMMAND)
|
||||||
output = fixture('update_git_pull_output_with_formulae_changes')
|
output = fixture('update_git_pull_output_with_formulae_changes')
|
||||||
updater.in_prefix_expect("git pull origin master", output)
|
updater.in_prefix_expect(RefreshBrew::UPDATE_COMMAND, output)
|
||||||
|
|
||||||
assert_equal true, updater.update_from_masterbrew!
|
assert_equal true, updater.update_from_masterbrew!
|
||||||
assert updater.pending_formulae_changes?
|
assert updater.pending_formulae_changes?
|
||||||
@ -95,7 +97,7 @@ class UpdaterTests < Test::Unit::TestCase
|
|||||||
def test_updater_returns_current_revision
|
def test_updater_returns_current_revision
|
||||||
outside_prefix do
|
outside_prefix do
|
||||||
updater = RefreshBrewMock.new
|
updater = RefreshBrewMock.new
|
||||||
updater.in_prefix_expect('git log -l -1 --pretty=format:%H', 'the-revision-hash')
|
updater.in_prefix_expect(RefreshBrew::REVISION_COMMAND, 'the-revision-hash')
|
||||||
assert_equal 'the-revision-hash', updater.current_revision
|
assert_equal 'the-revision-hash', updater.current_revision
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,10 +5,6 @@
|
|||||||
# Note: "formula_test" is omitted; these aren't unit tests but sanity checks
|
# Note: "formula_test" is omitted; these aren't unit tests but sanity checks
|
||||||
# on the real formulae.
|
# on the real formulae.
|
||||||
#
|
#
|
||||||
# Run as:
|
|
||||||
# ./tests -- --skip-update
|
|
||||||
# to omit the update tests which only seem to work for mxcl
|
|
||||||
#
|
|
||||||
|
|
||||||
# Feel free to split out test_bucket
|
# Feel free to split out test_bucket
|
||||||
ruby test_bucket.rb $*
|
ruby test_bucket.rb $*
|
||||||
@ -24,6 +20,4 @@ ruby test_pathname_install.rb $*
|
|||||||
ruby test_utils.rb $*
|
ruby test_utils.rb $*
|
||||||
ruby test_ARGV.rb $*
|
ruby test_ARGV.rb $*
|
||||||
ruby test_ENV.rb $*
|
ruby test_ENV.rb $*
|
||||||
|
|
||||||
# Update tests (only seem to work for mxcl)
|
|
||||||
ruby test_updater.rb $*
|
ruby test_updater.rb $*
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
class RefreshBrew
|
class RefreshBrew
|
||||||
RESPOSITORY_URL = 'git://github.com/mxcl/homebrew.git'
|
RESPOSITORY_URL = 'git://github.com/mxcl/homebrew.git'
|
||||||
|
INIT_COMMAND = "git init"
|
||||||
CHECKOUT_COMMAND = 'git checkout -q master'
|
CHECKOUT_COMMAND = 'git checkout -q master'
|
||||||
UPDATE_COMMAND = "git pull #{RESPOSITORY_URL} master"
|
UPDATE_COMMAND = "git pull #{RESPOSITORY_URL} master"
|
||||||
REVISION_COMMAND = 'git log -l -1 --pretty=format:%H 2> /dev/null'
|
REVISION_COMMAND = 'git log -l -1 --pretty=format:%H 2> /dev/null'
|
||||||
@ -60,7 +61,7 @@ class RefreshBrew
|
|||||||
|
|
||||||
def execute(cmd)
|
def execute(cmd)
|
||||||
out = `#{cmd}`
|
out = `#{cmd}`
|
||||||
unless $?.success?
|
if $? && !$?.success?
|
||||||
puts out
|
puts out
|
||||||
raise "Failed while executing #{cmd}"
|
raise "Failed while executing #{cmd}"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user