diff options
| author | Eloy Duran | 2009-09-11 10:52:32 +0200 |
|---|---|---|
| committer | Eloy Duran | 2009-09-17 00:24:11 +0200 |
| commit | c9f056c32763cbc8b92371cb38b51a4406aa1b6c (patch) | |
| tree | 455de5372b962f038fa98704a181f11f1ac55530 /Library/Homebrew | |
| parent | 52efea0e7d4340155b90a52223bccc7f9b8033ff (diff) | |
| download | brew-c9f056c32763cbc8b92371cb38b51a4406aa1b6c.tar.bz2 | |
Make sure git commands in RefreshBrew are executed with the proper working dir.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/refresh_brew.rb | 8 | ||||
| -rwxr-xr-x | Library/Homebrew/unittest.rb | 57 |
2 files changed, 41 insertions, 24 deletions
diff --git a/Library/Homebrew/refresh_brew.rb b/Library/Homebrew/refresh_brew.rb index 753036ed5..bc61061a2 100644 --- a/Library/Homebrew/refresh_brew.rb +++ b/Library/Homebrew/refresh_brew.rb @@ -25,12 +25,16 @@ class RefreshBrew end def current_revision - `#{REVISION_COMMAND}`.strip + in_prefix { `#{REVISION_COMMAND}`.strip } end private + def in_prefix + Dir.chdir(HOMEBREW_PREFIX) { yield } + end + def git_pull! - Dir.chdir(HOMEBREW_PREFIX) { `#{UPDATE_COMMAND}` } + in_prefix { `#{UPDATE_COMMAND}` } end end
\ No newline at end of file diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb index bc1cc6937..48e4650d4 100755 --- a/Library/Homebrew/unittest.rb +++ b/Library/Homebrew/unittest.rb @@ -502,41 +502,54 @@ class BeerTasting <Test::Unit::TestCase end def test_updater_update_homebrew_without_any_changes - updater = RefreshBrewMock.new - updater.in_prefix_expect("git pull origin masterbrew", "Already up-to-date.\n") - - assert_equal false, updater.update_from_masterbrew! - assert updater.updated_formulae.empty? + outside_prefix do + updater = RefreshBrewMock.new + updater.in_prefix_expect("git pull origin masterbrew", "Already up-to-date.\n") + + assert_equal false, updater.update_from_masterbrew! + assert updater.updated_formulae.empty? + end end def test_updater_update_homebrew_without_formulae_changes - updater = RefreshBrewMock.new - output = fixture('update_git_pull_output_without_formulae_changes') - updater.in_prefix_expect("git pull origin masterbrew", output) - - assert_equal true, updater.update_from_masterbrew! - assert !updater.pending_formulae_changes? - assert updater.updated_formulae.empty? + outside_prefix do + updater = RefreshBrewMock.new + output = fixture('update_git_pull_output_without_formulae_changes') + updater.in_prefix_expect("git pull origin masterbrew", output) + + assert_equal true, updater.update_from_masterbrew! + assert !updater.pending_formulae_changes? + assert updater.updated_formulae.empty? + end end def test_updater_update_homebrew_with_formulae_changes - updater = RefreshBrewMock.new - output = fixture('update_git_pull_output_with_formulae_changes') - updater.in_prefix_expect("git pull origin masterbrew", output) - - assert_equal true, updater.update_from_masterbrew! - assert updater.pending_formulae_changes? - assert_equal %w{ antiword bash-completion xar yajl }, updater.updated_formulae + outside_prefix do + updater = RefreshBrewMock.new + output = fixture('update_git_pull_output_with_formulae_changes') + updater.in_prefix_expect("git pull origin masterbrew", output) + + assert_equal true, updater.update_from_masterbrew! + assert updater.pending_formulae_changes? + assert_equal %w{ antiword bash-completion xar yajl }, updater.updated_formulae + end end def test_updater_returns_current_revision - updater = RefreshBrewMock.new - updater.in_prefix_expect('git log -l -1 --pretty=format:%H', 'the-revision-hash') - assert_equal 'the-revision-hash', updater.current_revision + outside_prefix do + updater = RefreshBrewMock.new + updater.in_prefix_expect('git log -l -1 --pretty=format:%H', 'the-revision-hash') + assert_equal 'the-revision-hash', updater.current_revision + end end private + OUTSIDE_PREFIX = '/tmp' + def outside_prefix + Dir.chdir(OUTSIDE_PREFIX) { yield } + end + def fixture(name) self.class.fixture_data[name] end |
