Move updater tests to separate file.

This commit is contained in:
Adam Vandenberg 2010-02-12 14:56:01 -08:00
parent fd453107c6
commit 9d127ac3d5
3 changed files with 38 additions and 26 deletions

View File

@ -1,3 +1,38 @@
abort if ARGV.include? "--skip-update"
require 'testing_env'
require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser
ARGV.extend(HomebrewArgvExtension)
require 'formula'
require 'utils'
require 'update'
class RefreshBrewMock < RefreshBrew
def in_prefix_expect(expect, returns = '')
@expect ||= {}
@expect[expect] = returns
end
def `(cmd)
if Dir.pwd == HOMEBREW_PREFIX.to_s and @expect.has_key?(cmd)
(@called ||= []) << cmd
@expect[cmd]
else
raise "#{inspect} Unexpectedly called backticks in pwd `#{HOMEBREW_PREFIX}' and command `#{cmd}'"
end
end
def expectations_met?
@expect.keys.sort == @called.sort
end
def inspect
"#<#{self.class.name} #{object_id}>"
end
end
class UpdaterTests < Test::Unit::TestCase class UpdaterTests < Test::Unit::TestCase
OUTSIDE_PREFIX = '/tmp' OUTSIDE_PREFIX = '/tmp'
def outside_prefix def outside_prefix

View File

@ -9,6 +9,9 @@
# Bulk of the tests # Bulk of the tests
ruby unittest.rb $* ruby unittest.rb $*
# Update tests (only seem to work for mxcl)
ruby test_updater.rb $*
# Patching tests # Patching tests
ruby test_patching.rb $* ruby test_patching.rb $*

View File

@ -30,7 +30,6 @@ require 'keg'
require 'utils' require 'utils'
require 'brew.h' require 'brew.h'
require 'hardware' require 'hardware'
require 'update'
# for some reason our utils.rb safe_system behaves completely differently # for some reason our utils.rb safe_system behaves completely differently
# during these tests. This is worrying for sure. # during these tests. This is worrying for sure.
@ -113,30 +112,6 @@ class TestScriptFileFormula <ScriptFileFormula
end end
end end
class RefreshBrewMock < RefreshBrew
def in_prefix_expect(expect, returns = '')
@expect ||= {}
@expect[expect] = returns
end
def `(cmd)
if Dir.pwd == HOMEBREW_PREFIX.to_s and @expect.has_key?(cmd)
(@called ||= []) << cmd
@expect[cmd]
else
raise "#{inspect} Unexpectedly called backticks in pwd `#{HOMEBREW_PREFIX}' and command `#{cmd}'"
end
end
def expectations_met?
@expect.keys.sort == @called.sort
end
def inspect
"#<#{self.class.name} #{object_id}>"
end
end
module ExtendArgvPlusYeast module ExtendArgvPlusYeast
def reset def reset
@named = nil @named = nil
@ -150,6 +125,5 @@ ARGV.extend ExtendArgvPlusYeast
require 'test/test_versions' require 'test/test_versions'
require 'test/test_checksums' require 'test/test_checksums'
require 'test/test_updater' unless ARGV.include? "--skip-update"
require 'test/test_bucket' require 'test/test_bucket'
require 'test/test_inreplace' require 'test/test_inreplace'