2011-06-23 18:11:55 -04:00
|
|
|
require 'rubygems'
|
2012-11-15 16:59:37 -05:00
|
|
|
$:.unshift File.expand_path('../../lib', __FILE__)
|
2011-07-23 01:38:50 -04:00
|
|
|
|
|
|
|
begin
|
|
|
|
gem 'minitest'
|
|
|
|
rescue Gem::LoadError
|
|
|
|
end
|
|
|
|
|
2011-06-23 18:11:55 -04:00
|
|
|
require 'minitest/autorun'
|
|
|
|
require 'rake'
|
|
|
|
require 'tmpdir'
|
|
|
|
require File.expand_path('../file_creation', __FILE__)
|
|
|
|
|
2013-10-11 17:35:01 -04:00
|
|
|
require_relative 'support/ruby_runner'
|
|
|
|
require_relative 'support/rakefile_definitions'
|
|
|
|
|
2011-07-23 01:38:50 -04:00
|
|
|
begin
|
2012-12-06 02:35:45 -05:00
|
|
|
require_relative '../ruby/envutil'
|
|
|
|
rescue NoMethodError, LoadError
|
2011-07-23 01:38:50 -04:00
|
|
|
# for ruby trunk
|
|
|
|
end
|
2011-06-23 18:11:55 -04:00
|
|
|
|
2011-07-23 01:38:50 -04:00
|
|
|
class Rake::TestCase < MiniTest::Unit::TestCase
|
2011-06-23 18:11:55 -04:00
|
|
|
include FileCreation
|
|
|
|
|
|
|
|
include Rake::DSL
|
|
|
|
|
|
|
|
class TaskManager
|
|
|
|
include Rake::TaskManager
|
|
|
|
end
|
|
|
|
|
2011-07-23 01:38:50 -04:00
|
|
|
RUBY = defined?(EnvUtil) ? EnvUtil.rubybin : Gem.ruby
|
|
|
|
|
2011-06-23 18:11:55 -04:00
|
|
|
def setup
|
|
|
|
ARGV.clear
|
|
|
|
|
2012-11-29 14:16:46 -05:00
|
|
|
test_dir = File.basename File.dirname File.expand_path __FILE__
|
|
|
|
|
2013-10-11 17:35:01 -04:00
|
|
|
@rake_root =
|
|
|
|
if test_dir == 'test'
|
|
|
|
# rake repository
|
|
|
|
File.expand_path '../../', __FILE__
|
|
|
|
else
|
|
|
|
# ruby repository
|
|
|
|
File.expand_path '../../../', __FILE__
|
|
|
|
end
|
|
|
|
|
|
|
|
@verbose = ENV['VERBOSE']
|
2012-11-29 14:16:46 -05:00
|
|
|
|
|
|
|
@rake_exec = File.join @rake_root, 'bin', 'rake'
|
|
|
|
@rake_lib = File.join @rake_root, 'lib'
|
2013-10-11 17:35:01 -04:00
|
|
|
@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']
|
2011-06-23 18:11:55 -04:00
|
|
|
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
|
2011-07-23 01:38:50 -04:00
|
|
|
RakeFileUtils.verbose_flag = false
|
2011-06-23 18:11:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
2013-10-11 17:35:01 -04:00
|
|
|
Dir.chdir @orig_pwd
|
2011-06-23 18:11:55 -04:00
|
|
|
FileUtils.rm_rf @tempdir
|
|
|
|
|
2013-10-11 17:35:01 -04:00
|
|
|
if @orig_appdata
|
|
|
|
ENV['APPDATA'] = @orig_appdata
|
2011-06-23 18:11:55 -04:00
|
|
|
else
|
|
|
|
ENV.delete 'APPDATA'
|
|
|
|
end
|
|
|
|
|
2013-10-11 17:35:01 -04:00
|
|
|
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
|
2011-06-23 18:11:55 -04:00
|
|
|
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
|
|
|
|
|
2013-10-11 17:35:01 -04:00
|
|
|
def rakefile(contents)
|
2011-06-23 18:11:55 -04:00
|
|
|
open 'Rakefile', 'w' do |io|
|
|
|
|
io << contents
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-11 17:35:01 -04:00
|
|
|
include RakefileDefinitions
|
2012-11-15 16:59:37 -05:00
|
|
|
end
|