aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/unittest.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2009-08-11 12:20:55 -0700
committerMax Howell2009-08-24 01:03:23 +0100
commit0eaf4bbcd9e4afb8a92a678ee072e8167e841527 (patch)
tree914109b77c2bfe864165521c2af84e26953dc27c /Library/Homebrew/unittest.rb
parent65e1419ea977c6ea1f4edd6ebf24f48c84fa0832 (diff)
downloadbrew-0eaf4bbcd9e4afb8a92a678ee072e8167e841527.tar.bz2
Factor out downloading from Formula
This patch adds a ArchiveDownloadStrategy that handles downloading tarbarlls and decompressing them into the staging area ready for brewing. Refactored safe_system and curl into utils.rb Signed-off-by: Max Howell <max@methylblue.com> Modifications to Adam's original patch: I reverted objectification of checksum verification because I couldn't think of any other download validation methods that might be useful to us in the future, so allowing such flexibility had no advantages. If we ever need this to be OO we can add it. But for now less complexity is preferable. I removed the @svnurl class member. Instead download_strategy is autodetected by examining the url. The user can override the download_strategy in case this fails. Thus we already can easily add support for clones of git repositories.
Diffstat (limited to 'Library/Homebrew/unittest.rb')
-rwxr-xr-xLibrary/Homebrew/unittest.rb26
1 files changed, 15 insertions, 11 deletions
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb
index 2ffb874ba..f3ea7c930 100755
--- a/Library/Homebrew/unittest.rb
+++ b/Library/Homebrew/unittest.rb
@@ -43,9 +43,9 @@ end
class TestZip <Formula
def initialize
- path=HOMEBREW_CACHE.parent+'test-0.1.zip'
- Kernel.system 'zip', '-0', path, __FILE__
- @url="file://#{path}"
+ zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
+ Kernel.system 'zip', '-0', zip, __FILE__
+ @url="file://#{zip}"
super 'testzip'
end
end
@@ -63,7 +63,6 @@ class TestBallOverrideBrew <Formula
super "foo"
end
def brew
- # We can't override brew
end
end
@@ -78,13 +77,18 @@ class TestScriptFileFormula <ScriptFileFormula
end
def nostdout
- require 'stringio'
- tmpo=$stdout
- tmpe=$stderr
- $stdout=StringIO.new
- yield
-ensure
- $stdout=tmpo
+ if ARGV.include? '-V'
+ yield
+ end
+ begin
+ require 'stringio'
+ tmpo=$stdout
+ tmpe=$stderr
+ $stdout=StringIO.new
+ yield
+ ensure
+ $stdout=tmpo
+ end
end