From 9d127ac3d58f99a744fe017f89ca64dcaeeed778 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Fri, 12 Feb 2010 14:56:01 -0800 Subject: [PATCH] Move updater tests to separate file. --- Library/Homebrew/test/test_updater.rb | 35 +++++++++++++++++++++++++++ Library/Homebrew/test/tests | 3 +++ Library/Homebrew/test/unittest.rb | 26 -------------------- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb index 8935899830..b94ec952a4 100644 --- a/Library/Homebrew/test/test_updater.rb +++ b/Library/Homebrew/test/test_updater.rb @@ -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 OUTSIDE_PREFIX = '/tmp' def outside_prefix diff --git a/Library/Homebrew/test/tests b/Library/Homebrew/test/tests index a63d5be35e..64aaf3109b 100755 --- a/Library/Homebrew/test/tests +++ b/Library/Homebrew/test/tests @@ -9,6 +9,9 @@ # Bulk of the tests ruby unittest.rb $* +# Update tests (only seem to work for mxcl) +ruby test_updater.rb $* + # Patching tests ruby test_patching.rb $* diff --git a/Library/Homebrew/test/unittest.rb b/Library/Homebrew/test/unittest.rb index 8dd298563a..49d6f6ad73 100755 --- a/Library/Homebrew/test/unittest.rb +++ b/Library/Homebrew/test/unittest.rb @@ -30,7 +30,6 @@ require 'keg' require 'utils' require 'brew.h' require 'hardware' -require 'update' # for some reason our utils.rb safe_system behaves completely differently # during these tests. This is worrying for sure. @@ -113,30 +112,6 @@ class TestScriptFileFormula " - end -end - module ExtendArgvPlusYeast def reset @named = nil @@ -150,6 +125,5 @@ ARGV.extend ExtendArgvPlusYeast require 'test/test_versions' require 'test/test_checksums' -require 'test/test_updater' unless ARGV.include? "--skip-update" require 'test/test_bucket' require 'test/test_inreplace'