Skip to content

Commit

Permalink
Fix the update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information
daporter authored and adamv committed May 12, 2010
1 parent e68ca2f commit 3a7a361
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
16 changes: 9 additions & 7 deletions Library/Homebrew/test/test_updater.rb
Expand Up @@ -23,6 +23,8 @@ def `(cmd)
raise "#{inspect} Unexpectedly called backticks in pwd `#{HOMEBREW_PREFIX}' and command `#{cmd}'"
end
end

alias safe_system `

def expectations_met?
@expect.keys.sort == @called.sort
Expand Down Expand Up @@ -54,8 +56,8 @@ def self.fixture_data
def test_update_homebrew_without_any_changes
outside_prefix do
updater = RefreshBrewMock.new
updater.in_prefix_expect("git checkout master")
updater.in_prefix_expect("git pull origin master", "Already up-to-date.\n")
updater.in_prefix_expect(RefreshBrew::INIT_COMMAND)
updater.in_prefix_expect(RefreshBrew::UPDATE_COMMAND, "Already up-to-date.\n")

assert_equal false, updater.update_from_masterbrew!
assert updater.expectations_met?
Expand All @@ -67,9 +69,9 @@ def test_update_homebrew_without_any_changes
def test_update_homebrew_without_formulae_changes
outside_prefix do
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')
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 !updater.pending_formulae_changes?
Expand All @@ -81,9 +83,9 @@ def test_update_homebrew_without_formulae_changes
def test_update_homebrew_with_formulae_changes
outside_prefix do
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')
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 updater.pending_formulae_changes?
Expand All @@ -95,7 +97,7 @@ def test_update_homebrew_with_formulae_changes
def test_updater_returns_current_revision
outside_prefix do
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
end
end
Expand Down
6 changes: 0 additions & 6 deletions Library/Homebrew/test/tests
Expand Up @@ -5,10 +5,6 @@
# Note: "formula_test" is omitted; these aren't unit tests but sanity checks
# 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
ruby test_bucket.rb $*
Expand All @@ -24,6 +20,4 @@ ruby test_pathname_install.rb $*
ruby test_utils.rb $*
ruby test_ARGV.rb $*
ruby test_ENV.rb $*

# Update tests (only seem to work for mxcl)
ruby test_updater.rb $*
3 changes: 2 additions & 1 deletion Library/Homebrew/update.rb
@@ -1,5 +1,6 @@
class RefreshBrew
RESPOSITORY_URL = 'git://github.com/mxcl/homebrew.git'
INIT_COMMAND = "git init"
CHECKOUT_COMMAND = 'git checkout -q master'
UPDATE_COMMAND = "git pull #{RESPOSITORY_URL} master"
REVISION_COMMAND = 'git log -l -1 --pretty=format:%H 2> /dev/null'
Expand Down Expand Up @@ -60,7 +61,7 @@ def in_prefix

def execute(cmd)
out = `#{cmd}`
unless $?.success?
if $? && !$?.success?
puts out
raise "Failed while executing #{cmd}"
end
Expand Down

0 comments on commit 3a7a361

Please sign in to comment.