2012-11-15 16:59:37 -05:00
|
|
|
require File.expand_path('../helper', __FILE__)
|
|
|
|
require 'open3'
|
|
|
|
|
|
|
|
class TestRakeReduceCompat < Rake::TestCase
|
|
|
|
# TODO: factor out similar code in test_rake_functional.rb
|
|
|
|
def rake(*args)
|
2012-11-15 22:49:09 -05:00
|
|
|
lib = File.expand_path('../../../lib', __FILE__)
|
|
|
|
bin_rake = File.expand_path('../../../bin/rake', __FILE__)
|
2012-11-15 16:59:37 -05:00
|
|
|
Open3.popen3(RUBY, "-I", lib, bin_rake, *args) { |_, out, _, _| out.read }
|
|
|
|
end
|
2012-11-16 01:41:05 -05:00
|
|
|
|
2012-11-15 16:59:37 -05:00
|
|
|
def invoke_normal(task_name)
|
|
|
|
rake task_name.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def invoke_reduce_compat(task_name)
|
|
|
|
rake "--reduce-compat", task_name.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_no_deprecated_dsl
|
|
|
|
rakefile %q{
|
|
|
|
task :check_task do
|
|
|
|
Module.new { p defined?(task) }
|
|
|
|
end
|
|
|
|
|
|
|
|
task :check_file do
|
|
|
|
Module.new { p defined?(file) }
|
|
|
|
end
|
|
|
|
}
|
2012-11-16 01:41:05 -05:00
|
|
|
|
2012-11-15 16:59:37 -05:00
|
|
|
assert_equal %{"method"}, invoke_normal(:check_task).chomp
|
|
|
|
assert_equal %{"method"}, invoke_normal(:check_file).chomp
|
|
|
|
|
|
|
|
assert_equal "nil", invoke_reduce_compat(:check_task).chomp
|
|
|
|
assert_equal "nil", invoke_reduce_compat(:check_file).chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_no_classic_namespace
|
|
|
|
rakefile %q{
|
|
|
|
task :check_task do
|
|
|
|
begin
|
|
|
|
Task
|
|
|
|
print "present"
|
|
|
|
rescue NameError
|
|
|
|
print "absent"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
task :check_file_task do
|
|
|
|
begin
|
|
|
|
FileTask
|
|
|
|
print "present"
|
|
|
|
rescue NameError
|
|
|
|
print "absent"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal "present", invoke_normal(:check_task)
|
|
|
|
assert_equal "present", invoke_normal(:check_file_task)
|
|
|
|
|
|
|
|
assert_equal "absent", invoke_reduce_compat(:check_task)
|
|
|
|
assert_equal "absent", invoke_reduce_compat(:check_file_task)
|
|
|
|
end
|
|
|
|
end
|