diff options
| author | Jack Nagel | 2015-04-28 22:37:26 -0400 |
|---|---|---|
| committer | Jack Nagel | 2015-04-29 19:15:11 -0400 |
| commit | 0397d68259b53b4c73e274d4047fe0e7529ade49 (patch) | |
| tree | a08ddd95a355ef65f089b0c12f2f127ecf2a496a /Library/Homebrew/test/testing_env.rb | |
| parent | ee0a553021e044929656de102fbb16c47fcdba3d (diff) | |
| download | brew-0397d68259b53b4c73e274d4047fe0e7529ade49.tar.bz2 | |
Extract runtime configuration from global.rb
This allows global.rb to be safely loaded in the test environment.
Diffstat (limited to 'Library/Homebrew/test/testing_env.rb')
| -rw-r--r-- | Library/Homebrew/test/testing_env.rb | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index fc5d80441..8e907e24a 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -1,51 +1,12 @@ -# Require this file to build a testing environment. - -$:.push(File.expand_path(__FILE__+'/../..')) - -require 'extend/module' -require 'extend/fileutils' -require 'extend/pathname' -require 'extend/ARGV' -require 'extend/string' -require 'extend/symbol' -require 'extend/enumerable' -require 'exceptions' -require 'utils' -require 'rbconfig' -require 'tmpdir' +$:.unshift File.expand_path("../..", __FILE__) +$:.unshift File.expand_path("../lib", __FILE__) + +require "tmpdir" TEST_TMPDIR = Dir.mktmpdir("homebrew_tests") at_exit { FileUtils.remove_entry(TEST_TMPDIR) } -# Constants normally defined in global.rb -HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix") -HOMEBREW_REPOSITORY = HOMEBREW_PREFIX -HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY+'Library' -HOMEBREW_CACHE = HOMEBREW_PREFIX.parent+'cache' -HOMEBREW_CACHE_FORMULA = HOMEBREW_PREFIX.parent+'formula_cache' -HOMEBREW_CELLAR = HOMEBREW_PREFIX.parent+'cellar' -HOMEBREW_LOGS = HOMEBREW_PREFIX.parent+'logs' -HOMEBREW_TEMP = Pathname.new(ENV.fetch('HOMEBREW_TEMP', '/tmp')) -HOMEBREW_USER_AGENT = 'Homebrew' -HOMEBREW_WWW = 'http://example.com' -HOMEBREW_CURL_ARGS = '-fsLA' -HOMEBREW_VERSION = '0.9-test' - -require 'tap_constants' - -if RbConfig.respond_to?(:ruby) - RUBY_PATH = Pathname.new(RbConfig.ruby) -else - RUBY_PATH = Pathname.new(RbConfig::CONFIG["bindir"]).join( - RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"] - ) -end -RUBY_BIN = RUBY_PATH.dirname - -MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp -MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] } - -ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze +require "global" # Test environment setup %w{ENV Formula}.each { |d| HOMEBREW_LIBRARY.join(d).mkpath } @@ -54,8 +15,6 @@ ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p # Test fixtures and files can be found relative to this path TEST_DIRECTORY = File.dirname(File.expand_path(__FILE__)) -ARGV.extend(HomebrewArgvExtension) - begin require "rubygems" require "minitest/autorun" @@ -65,9 +24,6 @@ rescue LoadError end module Homebrew - include FileUtils - extend self - module VersionAssertions def version v Version.new(v) |
