1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rake/helper.rb
drbrain 9cadc95b28 * NEWS (with all sufficient information):
* lib/rake:  Update to rake 10.1.0
* bin/rake:  ditto.
* test/rake:  ditto.

* NEWS:  Update NEWS to include rake 10.1.0 and links to release notes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 21:35:01 +00:00

128 lines
2.8 KiB
Ruby

require 'rubygems'
$:.unshift File.expand_path('../../lib', __FILE__)
begin
gem 'minitest'
rescue Gem::LoadError
end
require 'minitest/autorun'
require 'rake'
require 'tmpdir'
require File.expand_path('../file_creation', __FILE__)
require_relative 'support/ruby_runner'
require_relative 'support/rakefile_definitions'
begin
require_relative '../ruby/envutil'
rescue NoMethodError, LoadError
# for ruby trunk
end
class Rake::TestCase < MiniTest::Unit::TestCase
include FileCreation
include Rake::DSL
class TaskManager
include Rake::TaskManager
end
RUBY = defined?(EnvUtil) ? EnvUtil.rubybin : Gem.ruby
def setup
ARGV.clear
test_dir = File.basename File.dirname File.expand_path __FILE__
@rake_root =
if test_dir == 'test'
# rake repository
File.expand_path '../../', __FILE__
else
# ruby repository
File.expand_path '../../../', __FILE__
end
@verbose = ENV['VERBOSE']
@rake_exec = File.join @rake_root, 'bin', 'rake'
@rake_lib = File.join @rake_root, 'lib'
@ruby_options = ["-I#{@rake_lib}", "-I."]
@orig_pwd = Dir.pwd
@orig_appdata = ENV['APPDATA']
@orig_home = ENV['HOME']
@orig_homedrive = ENV['HOMEDRIVE']
@orig_homepath = ENV['HOMEPATH']
@orig_rake_columns = ENV['RAKE_COLUMNS']
@orig_rake_system = ENV['RAKE_SYSTEM']
@orig_rakeopt = ENV['RAKEOPT']
@orig_userprofile = ENV['USERPROFILE']
ENV.delete 'RAKE_COLUMNS'
ENV.delete 'RAKE_SYSTEM'
ENV.delete 'RAKEOPT'
tmpdir = Dir.chdir Dir.tmpdir do Dir.pwd end
@tempdir = File.join tmpdir, "test_rake_#{$$}"
FileUtils.mkdir_p @tempdir
Dir.chdir @tempdir
Rake.application = Rake::Application.new
Rake::TaskManager.record_task_metadata = true
RakeFileUtils.verbose_flag = false
end
def teardown
Dir.chdir @orig_pwd
FileUtils.rm_rf @tempdir
if @orig_appdata
ENV['APPDATA'] = @orig_appdata
else
ENV.delete 'APPDATA'
end
ENV['HOME'] = @orig_home
ENV['HOMEDRIVE'] = @orig_homedrive
ENV['HOMEPATH'] = @orig_homepath
ENV['RAKE_COLUMNS'] = @orig_rake_columns
ENV['RAKE_SYSTEM'] = @orig_rake_system
ENV['RAKEOPT'] = @orig_rakeopt
ENV['USERPROFILE'] = @orig_userprofile
end
def ignore_deprecations
Rake.application.options.ignore_deprecate = true
yield
ensure
Rake.application.options.ignore_deprecate = false
end
def rake_system_dir
@system_dir = 'system'
FileUtils.mkdir_p @system_dir
open File.join(@system_dir, 'sys1.rake'), 'w' do |io|
io << <<-SYS
task "sys1" do
puts "SYS1"
end
SYS
end
ENV['RAKE_SYSTEM'] = @system_dir
end
def rakefile(contents)
open 'Rakefile', 'w' do |io|
io << contents
end
end
include RakefileDefinitions
end