summaryrefslogtreecommitdiff
path: root/test/rake
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-15 03:07:37 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-15 03:07:37 +0000
commit6361928083d01906ab9d8782b6533b4ed7c834a0 (patch)
tree172488be8a74c9313d35b9cd7d53999cd55f561d /test/rake
parent031e1570b934d6b3a1e17ae8eb78a44dac8186d3 (diff)
* lib/rake.rb, lib/rake/*.rb: Upgrade to rake-10.3.2
[fix GH-668] * test/rake/*.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake')
-rw-r--r--test/rake/support/rakefile_definitions.rb34
-rw-r--r--test/rake/test_rake_application.rb186
-rw-r--r--test/rake/test_rake_application_options.rb17
-rw-r--r--test/rake/test_rake_backtrace.rb6
-rw-r--r--test/rake/test_rake_clean.rb15
-rw-r--r--test/rake/test_rake_cpu_counter.rb50
-rw-r--r--test/rake/test_rake_directory_task.rb6
-rw-r--r--test/rake/test_rake_file_task.rb64
-rw-r--r--test/rake/test_rake_functional.rb18
-rw-r--r--test/rake/test_rake_name_space.rb14
-rw-r--r--test/rake/test_rake_path_map.rb4
-rw-r--r--test/rake/test_rake_rules.rb26
-rw-r--r--test/rake/test_rake_task.rb16
-rw-r--r--test/rake/test_rake_task_argument_parsing.rb6
-rw-r--r--test/rake/test_rake_task_arguments.rb6
-rw-r--r--test/rake/test_rake_task_manager.rb20
-rw-r--r--test/rake/test_rake_test_task.rb24
17 files changed, 470 insertions, 42 deletions
diff --git a/test/rake/support/rakefile_definitions.rb b/test/rake/support/rakefile_definitions.rb
index 5cc2ae1293..d4311425f1 100644
--- a/test/rake/support/rakefile_definitions.rb
+++ b/test/rake/support/rakefile_definitions.rb
@@ -41,6 +41,16 @@ end
ACCESS
end
+ def rakefile_test_task
+ rakefile <<-RAKEFILE
+ require "rake/testtask"
+
+ Rake::TestTask.new(:unit) do |t|
+ t.description = "custom test task description"
+ end
+ RAKEFILE
+ end
+
def rakefile_chains
rakefile <<-DEFAULT
task :default => "play.app"
@@ -217,6 +227,30 @@ default: other
end
end
+ def rakefile_regenerate_imports
+ rakefile <<-REGENERATE_IMPORTS
+task :default
+
+task :regenerate do
+ open("deps", "w") do |f|
+ f << <<-CONTENT
+file "deps" => :regenerate
+puts "REGENERATED"
+ CONTENT
+ end
+end
+
+import "deps"
+ REGENERATE_IMPORTS
+
+ open "deps", "w" do |f|
+ f << <<-CONTENT
+file "deps" => :regenerate
+puts "INITIAL"
+ CONTENT
+ end
+ end
+
def rakefile_multidesc
rakefile <<-MULTIDESC
task :b
diff --git a/test/rake/test_rake_application.rb b/test/rake/test_rake_application.rb
index aa5ed39f80..1532be1c9b 100644
--- a/test/rake/test_rake_application.rb
+++ b/test/rake/test_rake_application.rb
@@ -9,6 +9,79 @@ class TestRakeApplication < Rake::TestCase
@app.options.rakelib = []
end
+ def setup_command_line(*options)
+ ARGV.clear
+ options.each do |option|
+ ARGV << option
+ end
+ end
+
+ def test_display_exception_details
+ begin
+ raise 'test'
+ rescue => ex
+ end
+
+ out, err = capture_io do
+ @app.display_error_message ex
+ end
+
+ assert_empty out
+
+ assert_match 'rake aborted!', err
+ assert_match __method__.to_s, err
+ end
+
+ def test_display_exception_details_cause
+ skip 'Exception#cause not implemented' unless
+ Exception.method_defined? :cause
+
+ begin
+ raise 'cause a'
+ rescue
+ begin
+ raise 'cause b'
+ rescue => ex
+ end
+ end
+
+ out, err = capture_io do
+ @app.display_error_message ex
+ end
+
+ assert_empty out
+
+ assert_match 'cause a', err
+ assert_match 'cause b', err
+ end
+
+ def test_display_exception_details_cause_loop
+ skip 'Exception#cause not implemented' unless
+ Exception.method_defined? :cause
+
+ begin
+ begin
+ raise 'cause a'
+ rescue => a
+ begin
+ raise 'cause b'
+ rescue
+ raise a
+ end
+ end
+ rescue => ex
+ end
+
+ out, err = capture_io do
+ @app.display_error_message ex
+ end
+
+ assert_empty out
+
+ assert_match 'cause a', err
+ assert_match 'cause b', err
+ end
+
def test_display_tasks
@app.options.show_tasks = :tasks
@app.options.show_task_pattern = //
@@ -193,6 +266,7 @@ class TestRakeApplication < Rake::TestCase
end
def test_load_rakefile_not_found
+ ARGV.clear
Dir.chdir @tempdir
ENV['RAKE_SYSTEM'] = 'not_exist'
@@ -201,8 +275,11 @@ class TestRakeApplication < Rake::TestCase
options.silent = true
end
+
ex = assert_raises(RuntimeError) do
- @app.instance_eval do raw_load_rakefile end
+ @app.instance_eval do
+ raw_load_rakefile
+ end
end
assert_match(/no rakefile found/i, ex.message)
@@ -295,8 +372,7 @@ class TestRakeApplication < Rake::TestCase
assert !@app.options.trace
valid_option = '--trace'
- ARGV.clear
- ARGV << valid_option
+ setup_command_line(valid_option)
@app.handle_options
@@ -305,8 +381,7 @@ class TestRakeApplication < Rake::TestCase
end
def test_handle_options_trace_default_is_stderr
- ARGV.clear
- ARGV << "--trace"
+ setup_command_line("--trace")
@app.handle_options
@@ -315,8 +390,7 @@ class TestRakeApplication < Rake::TestCase
end
def test_handle_options_trace_overrides_to_stdout
- ARGV.clear
- ARGV << "--trace=stdout"
+ setup_command_line("--trace=stdout")
@app.handle_options
@@ -327,8 +401,7 @@ class TestRakeApplication < Rake::TestCase
def test_handle_options_trace_does_not_eat_following_task_names
assert !@app.options.trace
- ARGV.clear
- ARGV << "--trace" << "sometask"
+ setup_command_line("--trace", "sometask")
@app.handle_options
assert ARGV.include?("sometask")
@@ -359,8 +432,7 @@ class TestRakeApplication < Rake::TestCase
def test_display_task_run
ran = false
- ARGV.clear
- ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""'
+ setup_command_line('-f', '-s', '--tasks', '--rakelib=""')
@app.last_description = "COMMENT"
@app.define_task(Rake::Task, "default")
out, = capture_io { @app.run }
@@ -372,8 +444,7 @@ class TestRakeApplication < Rake::TestCase
def test_display_prereqs
ran = false
- ARGV.clear
- ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""'
+ setup_command_line('-f', '-s', '--prereqs', '--rakelib=""')
@app.last_description = "COMMENT"
t = @app.define_task(Rake::Task, "default")
t.enhance([:a, :b])
@@ -389,44 +460,99 @@ class TestRakeApplication < Rake::TestCase
def test_bad_run
@app.intern(Rake::Task, "default").enhance { fail }
- ARGV.clear
- ARGV << '-f' << '-s' << '--rakelib=""'
- assert_raises(SystemExit) {
- _, err = capture_io { @app.run }
- assert_match(/see full trace/, err)
+ setup_command_line('-f', '-s', '--rakelib=""')
+ _, err = capture_io {
+ assert_raises(SystemExit){ @app.run }
}
+ assert_match(/see full trace/i, err)
ensure
ARGV.clear
end
def test_bad_run_with_trace
@app.intern(Rake::Task, "default").enhance { fail }
- ARGV.clear
- ARGV << '-f' << '-s' << '-t'
- assert_raises(SystemExit) {
- _, err = capture_io { @app.run }
- refute_match(/see full trace/, err)
+ setup_command_line('-f', '-s', '-t')
+ _, err = capture_io {
+ assert_raises(SystemExit) { @app.run }
}
+ refute_match(/see full trace/i, err)
ensure
ARGV.clear
end
def test_bad_run_with_backtrace
@app.intern(Rake::Task, "default").enhance { fail }
+ setup_command_line('-f', '-s', '--backtrace')
+ _, err = capture_io {
+ assert_raises(SystemExit) {
+ @app.run
+ }
+ }
+ refute_match(/see full trace/, err)
+ ensure
ARGV.clear
- ARGV << '-f' << '-s' << '--backtrace'
- assert_raises(SystemExit) {
- _, err = capture_io { @app.run }
- refute_match(/see full trace/, err)
+ end
+
+ CustomError = Class.new(RuntimeError)
+
+ def test_bad_run_includes_exception_name
+ @app.intern(Rake::Task, "default").enhance {
+ raise CustomError, "intentional"
+ }
+ setup_command_line('-f', '-s')
+ _, err = capture_io {
+ assert_raises(SystemExit) {
+ @app.run
+ }
}
+ assert_match(/CustomError: intentional/, err)
+ end
+
+ def test_rake_error_excludes_exception_name
+ @app.intern(Rake::Task, "default").enhance {
+ fail "intentional"
+ }
+ setup_command_line('-f', '-s')
+ _, err = capture_io {
+ assert_raises(SystemExit) {
+ @app.run
+ }
+ }
+ refute_match(/RuntimeError/, err)
+ assert_match(/intentional/, err)
+ end
+
+ def cause_supported?
+ ex = StandardError.new
+ ex.respond_to?(:cause)
+ end
+
+ def test_printing_original_exception_cause
+ custom_error = Class.new(StandardError)
+ @app.intern(Rake::Task, "default").enhance {
+ begin
+ raise custom_error, "Original Error"
+ rescue custom_error
+ raise custom_error, "Secondary Error"
+ end
+ }
+ setup_command_line('-f', '-s')
+ _ ,err = capture_io {
+ assert_raises(SystemExit) {
+ @app.run
+ }
+ }
+ if cause_supported?
+ assert_match(/Original Error/, err)
+ end
+ assert_match(/Secondary Error/, err)
ensure
ARGV.clear
end
def test_run_with_bad_options
@app.intern(Rake::Task, "default").enhance { fail }
- ARGV.clear
- ARGV << '-f' << '-s' << '--xyzzy'
+ setup_command_line('-f', '-s', '--xyzzy')
assert_raises(SystemExit) {
capture_io { @app.run }
}
@@ -500,14 +626,12 @@ class TestRakeApplication < Rake::TestCase
loader.instance_variable_set :@load_called, false
def loader.load arg
- raise 'called more than once' if @load_called
raise ArgumentError, arg unless arg == 'x.dummy'
@load_called = true
end
loader.instance_variable_set :@make_dummy_called, false
def loader.make_dummy
- raise 'called more than once' if @make_dummy_called
@make_dummy_called = true
end
diff --git a/test/rake/test_rake_application_options.rb b/test/rake/test_rake_application_options.rb
index b3220b8a97..a9ae4d9c00 100644
--- a/test/rake/test_rake_application_options.rb
+++ b/test/rake/test_rake_application_options.rb
@@ -111,14 +111,23 @@ class TestRakeApplicationOptions < Rake::TestCase
end
def test_jobs
+ flags([]) do |opts|
+ assert_nil opts.thread_pool_size
+ end
+ flags(['--jobs', '0'], ['-j', '0']) do |opts|
+ assert_equal 0, opts.thread_pool_size
+ end
+ flags(['--jobs', '1'], ['-j', '1']) do |opts|
+ assert_equal 0, opts.thread_pool_size
+ end
flags(['--jobs', '4'], ['-j', '4']) do |opts|
- assert_equal 4, opts.thread_pool_size
+ assert_equal 3, opts.thread_pool_size
end
flags(['--jobs', 'asdas'], ['-j', 'asdas']) do |opts|
- assert_equal 2, opts.thread_pool_size
+ assert_equal Rake.suggested_thread_count-1, opts.thread_pool_size
end
flags('--jobs', '-j') do |opts|
- assert_equal 2, opts.thread_pool_size
+ assert opts.thread_pool_size > 1_000_000, "thread pool size should be huge (was #{opts.thread_pool_size})"
end
end
@@ -449,7 +458,7 @@ class TestRakeApplicationOptions < Rake::TestCase
end
@app.instance_eval do
handle_options
- collect_tasks
+ collect_command_line_tasks
end
@tasks = @app.top_level_tasks
@app.options
diff --git a/test/rake/test_rake_backtrace.rb b/test/rake/test_rake_backtrace.rb
index 8db3b5ab54..a60f251cc9 100644
--- a/test/rake/test_rake_backtrace.rb
+++ b/test/rake/test_rake_backtrace.rb
@@ -12,6 +12,9 @@ class TestBacktraceSuppression < Rake::TestCase
def test_system_dir_suppressed
path = RbConfig::CONFIG['rubylibprefix']
+ skip if path.nil?
+ path = File.expand_path path
+
paths = [path + ":12"]
actual = Rake::Backtrace.collapse(paths)
@@ -21,6 +24,9 @@ class TestBacktraceSuppression < Rake::TestCase
def test_near_system_dir_isnt_suppressed
path = RbConfig::CONFIG['rubylibprefix']
+ skip if path.nil?
+ path = File.expand_path path
+
paths = [" " + path + ":12"]
actual = Rake::Backtrace.collapse(paths)
diff --git a/test/rake/test_rake_clean.rb b/test/rake/test_rake_clean.rb
index 5e38950d38..0bce7bc0b1 100644
--- a/test/rake/test_rake_clean.rb
+++ b/test/rake/test_rake_clean.rb
@@ -15,7 +15,7 @@ class TestRakeClean < Rake::TestCase
file_name = create_undeletable_file
out, _ = capture_io do
- Rake::Cleaner.cleanup(file_name, verbose: false)
+ Rake::Cleaner.cleanup(file_name, :verbose => false)
end
assert_match(/failed to remove/i, out)
@@ -23,6 +23,15 @@ class TestRakeClean < Rake::TestCase
remove_undeletable_file
end
+ def test_cleanup_ignores_missing_files
+ file_name = File.join(@tempdir, "missing_directory", "no_such_file")
+
+ out, _ = capture_io do
+ Rake::Cleaner.cleanup(file_name, :verbose => false)
+ end
+ refute_match(/failed to remove/i, out)
+ end
+
private
def create_undeletable_file
@@ -46,7 +55,7 @@ class TestRakeClean < Rake::TestCase
file_name = File.join(dir_name, "deleteme")
FileUtils.chmod(0777, dir_name)
FileUtils.chmod(0777, file_name)
- Rake::Cleaner.cleanup(file_name, verbose: false)
- Rake::Cleaner.cleanup(dir_name, verbose: false)
+ Rake::Cleaner.cleanup(file_name, :verbose => false)
+ Rake::Cleaner.cleanup(dir_name, :verbose => false)
end
end
diff --git a/test/rake/test_rake_cpu_counter.rb b/test/rake/test_rake_cpu_counter.rb
new file mode 100644
index 0000000000..ccf21d8ba6
--- /dev/null
+++ b/test/rake/test_rake_cpu_counter.rb
@@ -0,0 +1,50 @@
+require File.expand_path('../helper', __FILE__)
+
+class TestRakeCpuCounter < Rake::TestCase
+
+ def setup
+ super
+
+ @cpu_counter = Rake::CpuCounter.new
+ end
+
+ def test_count_via_win32
+ if Rake::Win32.windows? then
+ assert_kind_of Numeric, @cpu_counter.count_via_win32
+ else
+ assert_nil @cpu_counter.count_via_win32
+ end
+ end
+
+ def test_in_path_command
+ with_ruby_in_path do |ruby|
+ assert_equal ruby, @cpu_counter.in_path_command(ruby)
+ end
+ rescue Errno::ENOENT => e
+ raise unless e.message =~ /\bwhich\b/
+
+ skip 'cannot find which for this test'
+ end
+
+ def test_run
+ with_ruby_in_path do |ruby|
+ assert_equal 7, @cpu_counter.run(ruby, '-e', 'puts 3 + 4')
+ end
+ end
+
+ def with_ruby_in_path
+ ruby = File.basename Gem.ruby
+ ruby_dir = File.dirname Gem.ruby
+
+ begin
+ orig_path, ENV['PATH'] =
+ ENV['PATH'], [ruby_dir, *ENV['PATH']].join(File::PATH_SEPARATOR)
+
+ yield ruby
+ ensure
+ ENV['PATH'] = orig_path
+ end
+ end
+
+end
+
diff --git a/test/rake/test_rake_directory_task.rb b/test/rake/test_rake_directory_task.rb
index 8ae7537b50..c8275e6d10 100644
--- a/test/rake/test_rake_directory_task.rb
+++ b/test/rake/test_rake_directory_task.rb
@@ -25,6 +25,12 @@ class TestRakeDirectoryTask < Rake::TestCase
refute File.exist?("a/b/c")
end
+ def test_directory_colon
+ directory "a:b"
+
+ assert_equal FileCreationTask, Task['a:b'].class
+ end unless Rake::Win32.windows?
+
if Rake::Win32.windows?
def test_directory_win32
desc "WIN32 DESC"
diff --git a/test/rake/test_rake_file_task.rb b/test/rake/test_rake_file_task.rb
index fa3241b78b..ae828c9ba1 100644
--- a/test/rake/test_rake_file_task.rb
+++ b/test/rake/test_rake_file_task.rb
@@ -98,6 +98,70 @@ class TestRakeFileTask < Rake::TestCase
assert @ran
end
+ def test_needed_eh_build_all
+ create_file 'a'
+
+ file 'a'
+
+ a_task = Task['a']
+
+ refute a_task.needed?
+
+ Rake.application.options.build_all = true
+
+ assert a_task.needed?
+ ensure
+ delete_file 'a'
+ end
+
+ def test_needed_eh_dependency
+ create_file 'a', Time.now
+ create_file 'b', Time.now - 60
+
+ create_file 'c', Time.now
+ create_file 'd', Time.now - 60
+
+ file 'b' => 'a'
+
+ b_task = Task['b']
+
+ assert b_task.needed?
+
+ file 'c' => 'd'
+
+ c_task = Task['c']
+
+ refute c_task.needed?
+ ensure
+ delete_file 'old'
+ delete_file 'new'
+ end
+
+ def test_needed_eh_exists
+ name = "dummy"
+ file name
+
+ ftask = Task[name]
+
+ assert ftask.needed?
+
+ create_file name
+
+ refute ftask.needed?
+ ensure
+ delete_file name
+ end
+
+ def test_source_is_first_prerequisite
+ t = file :f => ["preqA", "preqB"]
+ assert_equal "preqA", t.source
+ end
+
+ def test_sources_is_all_prerequisites
+ t = file :f => ["preqA", "preqB"]
+ assert_equal ["preqA", "preqB"], t.sources
+ end
+
# I have currently disabled this test. I'm not convinced that
# deleting the file target on failure is always the proper thing to
# do. I'm willing to hear input on this topic.
diff --git a/test/rake/test_rake_functional.rb b/test/rake/test_rake_functional.rb
index f2ce2f78f0..bf7ba92f75 100644
--- a/test/rake/test_rake_functional.rb
+++ b/test/rake/test_rake_functional.rb
@@ -268,6 +268,14 @@ class TestRakeFunctional < Rake::TestCase
assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
end
+ def test_regenerate_imports
+ rakefile_regenerate_imports
+
+ rake
+
+ assert_match(/^INITIAL\s+^REGENERATED$/, @out)
+ end
+
def test_rules_chaining_to_file_task
rakefile_chains
@@ -368,6 +376,14 @@ class TestRakeFunctional < Rake::TestCase
assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
end
+ def test_test_task_descriptions
+ rakefile_test_task
+
+ rake "-T"
+
+ assert_match(/custom test task description/, @out)
+ end
+
def test_comment_before_task_acts_like_desc
rakefile_comments
@@ -414,7 +430,7 @@ class TestRakeFunctional < Rake::TestCase
end
def can_detect_signals?
- system "ruby -e 'Process.kill \"TERM\", $$'"
+ system RUBY, '-e', 'Process.kill "TERM", $$'
status = $?
if @verbose
puts " SIG status = #{$?.inspect}"
diff --git a/test/rake/test_rake_name_space.rb b/test/rake/test_rake_name_space.rb
index 3ab977d013..d35e70e175 100644
--- a/test/rake/test_rake_name_space.rb
+++ b/test/rake/test_rake_name_space.rb
@@ -40,4 +40,18 @@ class TestRakeNameSpace < Rake::TestCase
ns.tasks.map { |tsk| tsk.name }
assert_equal ["n:nn:z"], nns.tasks.map { |t| t.name }
end
+
+ def test_scope
+ mgr = TM.new
+
+ scope = Rake::LinkedList.new 'b'
+ scope = scope.conj 'a'
+
+ ns = Rake::NameSpace.new mgr, scope
+
+ assert_equal scope, ns.scope
+
+ refute_same scope, ns.scope
+ end
+
end
diff --git a/test/rake/test_rake_path_map.rb b/test/rake/test_rake_path_map.rb
index b76a9491f9..038ba1f9a7 100644
--- a/test/rake/test_rake_path_map.rb
+++ b/test/rake/test_rake_path_map.rb
@@ -156,8 +156,8 @@ class TestRakePathMap < Rake::TestCase
"src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class"))
assert_equal(
"src_work/bin/org/onstepback/proj/A.class",
- "src_work/src/org/onstepback/proj/A.java"
- .pathmap('%{\bsrc\b,bin}X.class'))
+ "src_work/src/org/onstepback/proj/A.java".
+ pathmap('%{\bsrc\b,bin}X.class'))
assert_equal(
".depends.bak",
".depends".pathmap("%X.bak"))
diff --git a/test/rake/test_rake_rules.rb b/test/rake/test_rake_rules.rb
index 376b99889c..ece75e5d9e 100644
--- a/test/rake/test_rake_rules.rb
+++ b/test/rake/test_rake_rules.rb
@@ -359,4 +359,30 @@ class TestRakeRules < Rake::TestCase
Task[OBJFILE].invoke('arg')
end
+ def test_rule_with_method_prereq
+ create_file(".foo")
+ obj = Object.new
+ def obj.find_prereq
+ ".foo"
+ end
+ rule '.o' => obj.method(:find_prereq) do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task[OBJFILE].invoke
+ assert_equal ["#{OBJFILE} - .foo"], @runs
+ end
+
+ def test_rule_with_one_arg_method_prereq
+ create_file(SRCFILE)
+ obj = Object.new
+ def obj.find_prereq(task_name)
+ task_name.ext(".c")
+ end
+ rule '.o' => obj.method(:find_prereq) do |t|
+ @runs << "#{t.name} - #{t.source}"
+ end
+ Task[OBJFILE].invoke
+ assert_equal ["#{OBJFILE} - abc.c"], @runs
+ end
+
end
diff --git a/test/rake/test_rake_task.rb b/test/rake/test_rake_task.rb
index ed5f1b1e11..d7f14efcdb 100644
--- a/test/rake/test_rake_task.rb
+++ b/test/rake/test_rake_task.rb
@@ -333,6 +333,17 @@ class TestRakeTask < Rake::TestCase
assert_equal "Revision 1.2.3", t.comment
end
+ def test_comments_do_not_set
+ t = task(:t, :name, :rev)
+ assert_equal nil, t.comment
+ end
+
+ def test_comments_is_nil
+ t = task(:t, :name, :rev)
+ t.comment = nil
+ assert_equal nil, t.comment
+ end
+
def test_extended_comments
desc %{
This is a comment.
@@ -374,4 +385,9 @@ class TestRakeTask < Rake::TestCase
task(:t)
assert_equal "line one / line two", t.comment
end
+
+ def test_source_is_first_prerequisite
+ t = task :t => ["preqA", "preqB"]
+ assert_equal "preqA", t.source
+ end
end
diff --git a/test/rake/test_rake_task_argument_parsing.rb b/test/rake/test_rake_task_argument_parsing.rb
index 9b99991de9..0294a9fb2c 100644
--- a/test/rake/test_rake_task_argument_parsing.rb
+++ b/test/rake/test_rake_task_argument_parsing.rb
@@ -43,6 +43,12 @@ class TestRakeTaskArgumentParsing < Rake::TestCase
assert_equal ["a one ana", "two"], args
end
+ def test_can_handle_commas_in_args
+ name, args = @app.parse_task_string("name[one, two, three_a\\, three_b, four]")
+ assert_equal "name", name
+ assert_equal ["one", "two", "three_a, three_b", "four"], args
+ end
+
def test_terminal_width_using_env
app = Rake::Application.new
app.terminal_columns = 1234
diff --git a/test/rake/test_rake_task_arguments.rb b/test/rake/test_rake_task_arguments.rb
index 061178e23e..369ecf6e5c 100644
--- a/test/rake/test_rake_task_arguments.rb
+++ b/test/rake/test_rake_task_arguments.rb
@@ -19,6 +19,12 @@ class TestRakeTaskArguments < Rake::TestCase
assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash)
end
+ def test_has_key
+ ta = Rake::TaskArguments.new([:a], [:one])
+ assert(ta.has_key?(:a))
+ refute(ta.has_key?(:b))
+ end
+
def test_to_s
ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
assert_equal ta.to_hash.inspect, ta.to_s
diff --git a/test/rake/test_rake_task_manager.rb b/test/rake/test_rake_task_manager.rb
index 5ec4c0e65c..c2730b67e2 100644
--- a/test/rake/test_rake_task_manager.rb
+++ b/test/rake/test_rake_task_manager.rb
@@ -40,6 +40,23 @@ class TestRakeTaskManager < Rake::TestCase
assert_equal ["x:t"], @tm.tasks.map { |t| t.name }
end
+ def test_define_namespaced_task
+ t = @tm.define_task(Rake::Task, 'n:a:m:e:t')
+ assert_equal Rake::Scope.make("e", "m", "a", "n"), t.scope
+ assert_equal "n:a:m:e:t", t.name
+ assert_equal @tm, t.application
+ end
+
+ def test_define_namespace_in_namespace
+ t = nil
+ @tm.in_namespace("n") do
+ t = @tm.define_task(Rake::Task, 'a:m:e:t')
+ end
+ assert_equal Rake::Scope.make("e", "m", "a", "n"), t.scope
+ assert_equal "n:a:m:e:t", t.name
+ assert_equal @tm, t.application
+ end
+
def test_anonymous_namespace
anon_ns = @tm.in_namespace(nil) do
t = @tm.define_task(Rake::Task, :t)
@@ -89,6 +106,7 @@ class TestRakeTaskManager < Rake::TestCase
@tm.in_namespace("a") do
aa = @tm.define_task(Rake::Task, :aa)
mid_z = @tm.define_task(Rake::Task, :z)
+ ns_d = @tm.define_task(Rake::Task, "n:t")
@tm.in_namespace("b") do
bb = @tm.define_task(Rake::Task, :bb)
bot_z = @tm.define_task(Rake::Task, :z)
@@ -116,6 +134,8 @@ class TestRakeTaskManager < Rake::TestCase
assert_equal top_z, @tm["^z"]
assert_equal top_z, @tm["^^z"] # Over the top
assert_equal top_z, @tm["rake:z"]
+ assert_equal ns_d, @tm["n:t"]
+ assert_equal ns_d, @tm["a:n:t"]
end
assert_equal Rake::Scope.make, @tm.current_scope
diff --git a/test/rake/test_rake_test_task.rb b/test/rake/test_rake_test_task.rb
index 637accc291..9b500dc044 100644
--- a/test/rake/test_rake_test_task.rb
+++ b/test/rake/test_rake_test_task.rb
@@ -16,11 +16,13 @@ class TestRakeTestTask < Rake::TestCase
def test_initialize_override
tt = Rake::TestTask.new(:example) do |t|
+ t.description = "Run example tests"
t.libs = ['src', 'ext']
t.pattern = 'test/tc_*.rb'
t.verbose = true
end
refute_nil tt
+ assert_equal "Run example tests", tt.description
assert_equal :example, tt.name
assert_equal ['src', 'ext'], tt.libs
assert_equal 'test/tc_*.rb', tt.pattern
@@ -81,11 +83,31 @@ class TestRakeTestTask < Rake::TestCase
end
def test_run_code_rake
+ spec = Gem::Specification.new 'rake', 0
+ spec.loaded_from = File.join Gem::Specification.dirs.last, 'rake-0.gemspec'
+ rake, Gem.loaded_specs['rake'] = Gem.loaded_specs['rake'], spec
+
+ test_task = Rake::TestTask.new do |t|
+ t.loader = :rake
+ end
+
+ assert_match(/\A-I".*?" ".*?"\Z/, test_task.run_code)
+ ensure
+ Gem.loaded_specs['rake'] = rake
+ end
+
+ def test_run_code_rake_default_gem
+ default_spec = Gem::Specification.new 'rake', 0
+ default_spec.loaded_from = File.join Gem::Specification.default_specifications_dir, 'rake-0.gemspec'
+ rake, Gem.loaded_specs['rake'] = Gem.loaded_specs['rake'], default_spec
+
test_task = Rake::TestTask.new do |t|
t.loader = :rake
end
- assert_match(/-I".*?" ".*?"/, test_task.run_code)
+ assert_match(/\A ".*?"\Z/, test_task.run_code)
+ ensure
+ Gem.loaded_specs['rake'] = rake
end
def test_run_code_testrb_ruby_1_8_2