From fff3f0ae0cec1061f8b3e5cb44e189e94a4ad44f Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 13 Sep 2009 15:10:29 -0500 Subject: Detect missing dependencies and automatically run bundler --- activesupport/Gemfile | 1 - activesupport/Rakefile | 10 ---------- activesupport/test/abstract_unit.rb | 4 ++-- activesupport/test/bundler_helper.rb | 30 ++++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 activesupport/test/bundler_helper.rb (limited to 'activesupport') diff --git a/activesupport/Gemfile b/activesupport/Gemfile index c41e742058..5423d6f405 100644 --- a/activesupport/Gemfile +++ b/activesupport/Gemfile @@ -13,7 +13,6 @@ gem 'i18n', '0.1.3', :vendored_at => vendor_dir.join('i18n-0.1.3') only :test do gem 'mocha', '>= 0.9.7' - gem 'ruby-prof', '>= 0.6.1' end disable_rubygems diff --git a/activesupport/Rakefile b/activesupport/Rakefile index ecf8b52fc5..91c874d729 100644 --- a/activesupport/Rakefile +++ b/activesupport/Rakefile @@ -28,16 +28,6 @@ task :isolated_test do end or raise "Failures" end -task :bundle do - puts "Checking if the bundled testing requirements are up to date..." - result = system "gem bundle" - unless result - puts "The gem bundler is not installed. Installing." - system "gem install bundler" - system "gem bundle" - end -end - # Create compressed packages dist_dirs = [ "lib", "test"] diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index e06faadacb..eb73f1978e 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -1,7 +1,7 @@ ORIG_ARGV = ARGV.dup -bundler = File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment') -require bundler if File.exist?("#{bundler}.rb") +require 'bundler_helper' +ensure_requirable %w( builder memcache tzinfo mocha ) require 'test/unit' diff --git a/activesupport/test/bundler_helper.rb b/activesupport/test/bundler_helper.rb new file mode 100644 index 0000000000..5f3e982f19 --- /dev/null +++ b/activesupport/test/bundler_helper.rb @@ -0,0 +1,30 @@ +BUNDLER_ENV_FILE = File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment') + +def load_bundled_gems + load_bundled_gems! if File.exist?("#{BUNDLER_ENV_FILE}.rb") +end + +def load_bundled_gems! + puts "Checking if the bundled testing requirements are up to date..." + + result = system "gem bundle" + unless result + puts "The gem bundler is not installed. Installing." + system "gem install bundler" + system "gem bundle" + end + + require BUNDLER_ENV_FILE +end + +def ensure_requirable(libs) + load_bundled_gems + + begin + libs.each { |lib| require lib } + rescue LoadError => e + puts "Missing required libs to run test" + puts e.message + load_bundled_gems! + end +end -- cgit v1.2.3