Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix the update tests

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information...
commit 3a7a3619f7016c75c3e53e944221bf7f6354a63b 1 parent e68ca2f
@phunculist phunculist authored adamv committed
View
16 Library/Homebrew/test/test_updater.rb
@@ -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
@@ -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?
@@ -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?
@@ -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?
@@ -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
View
6 Library/Homebrew/test/tests
@@ -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 $*
@@ -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 $*
View
3  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'
@@ -60,7 +61,7 @@ def in_prefix
def execute(cmd)
out = `#{cmd}`
- unless $?.success?
+ if $? && !$?.success?
puts out
raise "Failed while executing #{cmd}"
end
Please sign in to comment.
Something went wrong with that request. Please try again.