Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created September 29, 2009 19:56
Show Gist options
  • Save thinkerbot/197247 to your computer and use it in GitHub Desktop.
Save thinkerbot/197247 to your computer and use it in GitHub Desktop.
CC Gemfile and Rakefile Prototypes
spec = eval(File.read('project.gemspec'))
gem "#{spec.name}", "#{spec.version}"
bin_path "vendor/gems/bin"
if ENV['BUNDLE_CC'] == "true"
# in the CC environment, bundles against the
# most recent working copies of a gemspec
clear_sources
cc_dir = ENV['CRUISE_DATA_ROOT'] || File.dirname(__FILE__) + "/../../.."
glob_source cc_dir, "projects/*/work/*.gemspec", "gems/gems/*/*.gemspec"
else
# vendors self, and allows gem dependencies
# under the submodule dir
source "http://gems.github.com"
glob_source File.dirname(__FILE__), "*.gemspec", "vendor/*/*.gemspec"
end
# Unfortunately rubygems cannot be disabled because (at least)
# ActiveSupport leverages a gem load error to correctly create
# load paths:
#
# [active_support/vendor.rb]
# Prefer gems to the bundled libs.
# require 'rubygems'
#
# begin
# gem 'builder', '~> 2.1.2'
# rescue Gem::LoadError
# $:.unshift "#{File.dirname(__FILE__)}/vendor/builder-2.1.2"
# end
# require 'builder'
# ...
#
# System gems CAN be disabled, however, so we know no gems will
# be loaded beyond those bundled.
disable_system_gems
require 'rake'
desc 'Run the unit tests'
task :test do
unless File.exists?("vendor/gems/environment.rb")
puts %Q{
Tests cannot be run until the dependencies have been
bundled. Use these commands and try again:
% git submodule init
% git submodule update
% gem bundle
}
exit(1) # important for CC to fail properly
end
tests = Dir.glob('test/**/*_test.rb')
cmd = ['ruby', "-w", '-rvendor/gems/environment.rb', "-e", "ARGV.dup.each {|test| load test}"] + tests
sh(*cmd)
end
desc "Update bundle for CruiseControl"
task :cc_bundle do
FileUtils.rm_r("vendor/gems") if File.exists?("vendor/gems")
system("BUNDLE_CC='true' gem bundle")
end
desc 'Run the cc tests'
task :cc => [:cc_bundle, :test]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment