rake 10.1.1 → 10.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -0
  4. data/.rubocop.yml +27 -0
  5. data/.togglerc +7 -0
  6. data/Gemfile +5 -0
  7. data/{CHANGES → History.rdoc} +84 -54
  8. data/Manifest.txt +161 -0
  9. data/README.rdoc +9 -10
  10. data/Rakefile +34 -337
  11. data/doc/command_line_usage.rdoc +16 -10
  12. data/doc/rake.1.gz +0 -0
  13. data/doc/rakefile.rdoc +72 -36
  14. data/doc/release_notes/rake-0.5.3.rdoc +1 -1
  15. data/doc/release_notes/rake-0.5.4.rdoc +1 -1
  16. data/doc/release_notes/rake-0.8.6.rdoc +1 -19
  17. data/doc/release_notes/rake-0.9.2.2.rdoc +2 -2
  18. data/doc/release_notes/rake-0.9.4.rdoc +0 -50
  19. data/doc/release_notes/rake-0.9.5.rdoc +0 -59
  20. data/doc/release_notes/rake-0.9.6.rdoc +0 -63
  21. data/doc/release_notes/rake-10.0.1.rdoc +2 -131
  22. data/doc/release_notes/rake-10.0.2.rdoc +2 -140
  23. data/doc/release_notes/rake-10.1.0.rdoc +2 -2
  24. data/lib/rake.rb +6 -1
  25. data/lib/rake/alt_system.rb +5 -3
  26. data/lib/rake/application.rb +102 -60
  27. data/lib/rake/backtrace.rb +1 -1
  28. data/lib/rake/cloneable.rb +3 -3
  29. data/lib/rake/contrib/.document +0 -0
  30. data/lib/rake/contrib/ftptools.rb +3 -5
  31. data/lib/rake/contrib/publisher.rb +12 -4
  32. data/lib/rake/contrib/rubyforgepublisher.rb +3 -1
  33. data/lib/rake/contrib/sshpublisher.rb +13 -2
  34. data/lib/rake/contrib/sys.rb +2 -0
  35. data/lib/rake/cpu_counter.rb +104 -0
  36. data/lib/rake/default_loader.rb +4 -0
  37. data/lib/rake/dsl_definition.rb +58 -17
  38. data/lib/rake/early_time.rb +4 -1
  39. data/lib/rake/ext/core.rb +2 -5
  40. data/lib/rake/ext/module.rb +1 -0
  41. data/lib/rake/ext/string.rb +35 -28
  42. data/lib/rake/ext/time.rb +1 -1
  43. data/lib/rake/file_list.rb +7 -9
  44. data/lib/rake/file_task.rb +1 -1
  45. data/lib/rake/gempackagetask.rb +3 -1
  46. data/lib/rake/invocation_chain.rb +0 -1
  47. data/lib/rake/linked_list.rb +1 -1
  48. data/lib/rake/packagetask.rb +19 -7
  49. data/lib/rake/pathmap.rb +2 -0
  50. data/lib/rake/pseudo_status.rb +2 -2
  51. data/lib/rake/rake_module.rb +6 -5
  52. data/lib/rake/rdoctask.rb +2 -0
  53. data/lib/rake/ruby182_test_unit_fix.rb +2 -0
  54. data/lib/rake/runtest.rb +6 -1
  55. data/lib/rake/scope.rb +1 -1
  56. data/lib/rake/task.rb +14 -9
  57. data/lib/rake/task_arguments.rb +19 -10
  58. data/lib/rake/task_manager.rb +20 -8
  59. data/lib/rake/tasklib.rb +2 -0
  60. data/lib/rake/testtask.rb +20 -9
  61. data/lib/rake/thread_pool.rb +13 -10
  62. data/lib/rake/trace_output.rb +1 -1
  63. data/lib/rake/version.rb +0 -2
  64. data/lib/rake/win32.rb +1 -1
  65. data/rakelib/publish.rake +20 -0
  66. data/rakelib/test_times.rake +25 -0
  67. data/test/helper.rb +6 -7
  68. data/test/support/rakefile_definitions.rb +34 -0
  69. data/test/test_rake_application.rb +89 -31
  70. data/test/test_rake_application_options.rb +13 -4
  71. data/test/test_rake_backtrace.rb +6 -2
  72. data/test/test_rake_clean.rb +3 -3
  73. data/test/test_rake_cpu_counter.rb +42 -0
  74. data/test/test_rake_file_task.rb +10 -0
  75. data/test/test_rake_functional.rb +17 -1
  76. data/test/test_rake_path_map.rb +2 -2
  77. data/test/test_rake_rules.rb +26 -0
  78. data/test/test_rake_task.rb +16 -0
  79. data/test/test_rake_task_argument_parsing.rb +6 -0
  80. data/test/test_rake_task_arguments.rb +6 -0
  81. data/test/test_rake_task_manager.rb +20 -0
  82. data/test/test_rake_test_task.rb +23 -1
  83. metadata +196 -72
  84. metadata.gz.sig +0 -0
  85. data/TODO +0 -21
  86. data/install.rb +0 -80
@@ -9,6 +9,13 @@ class TestRakeApplication < Rake::TestCase
9
9
  @app.options.rakelib = []
10
10
  end
11
11
 
12
+ def setup_command_line(*options)
13
+ ARGV.clear
14
+ options.each do |option|
15
+ ARGV << option
16
+ end
17
+ end
18
+
12
19
  def test_display_tasks
13
20
  @app.options.show_tasks = :tasks
14
21
  @app.options.show_task_pattern = //
@@ -193,6 +200,7 @@ class TestRakeApplication < Rake::TestCase
193
200
  end
194
201
 
195
202
  def test_load_rakefile_not_found
203
+ ARGV.clear
196
204
  Dir.chdir @tempdir
197
205
  ENV['RAKE_SYSTEM'] = 'not_exist'
198
206
 
@@ -201,8 +209,11 @@ class TestRakeApplication < Rake::TestCase
201
209
  options.silent = true
202
210
  end
203
211
 
212
+
204
213
  ex = assert_raises(RuntimeError) do
205
- @app.instance_eval do raw_load_rakefile end
214
+ @app.instance_eval do
215
+ raw_load_rakefile
216
+ end
206
217
  end
207
218
 
208
219
  assert_match(/no rakefile found/i, ex.message)
@@ -295,8 +306,7 @@ class TestRakeApplication < Rake::TestCase
295
306
  assert !@app.options.trace
296
307
 
297
308
  valid_option = '--trace'
298
- ARGV.clear
299
- ARGV << valid_option
309
+ setup_command_line(valid_option)
300
310
 
301
311
  @app.handle_options
302
312
 
@@ -305,8 +315,7 @@ class TestRakeApplication < Rake::TestCase
305
315
  end
306
316
 
307
317
  def test_handle_options_trace_default_is_stderr
308
- ARGV.clear
309
- ARGV << "--trace"
318
+ setup_command_line("--trace")
310
319
 
311
320
  @app.handle_options
312
321
 
@@ -315,8 +324,7 @@ class TestRakeApplication < Rake::TestCase
315
324
  end
316
325
 
317
326
  def test_handle_options_trace_overrides_to_stdout
318
- ARGV.clear
319
- ARGV << "--trace=stdout"
327
+ setup_command_line("--trace=stdout")
320
328
 
321
329
  @app.handle_options
322
330
 
@@ -327,8 +335,7 @@ class TestRakeApplication < Rake::TestCase
327
335
  def test_handle_options_trace_does_not_eat_following_task_names
328
336
  assert !@app.options.trace
329
337
 
330
- ARGV.clear
331
- ARGV << "--trace" << "sometask"
338
+ setup_command_line("--trace", "sometask")
332
339
 
333
340
  @app.handle_options
334
341
  assert ARGV.include?("sometask")
@@ -359,8 +366,7 @@ class TestRakeApplication < Rake::TestCase
359
366
 
360
367
  def test_display_task_run
361
368
  ran = false
362
- ARGV.clear
363
- ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""'
369
+ setup_command_line('-f', '-s', '--tasks', '--rakelib=""')
364
370
  @app.last_description = "COMMENT"
365
371
  @app.define_task(Rake::Task, "default")
366
372
  out, = capture_io { @app.run }
@@ -372,8 +378,7 @@ class TestRakeApplication < Rake::TestCase
372
378
 
373
379
  def test_display_prereqs
374
380
  ran = false
375
- ARGV.clear
376
- ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""'
381
+ setup_command_line('-f', '-s', '--prereqs', '--rakelib=""')
377
382
  @app.last_description = "COMMENT"
378
383
  t = @app.define_task(Rake::Task, "default")
379
384
  t.enhance([:a, :b])
@@ -389,44 +394,99 @@ class TestRakeApplication < Rake::TestCase
389
394
 
390
395
  def test_bad_run
391
396
  @app.intern(Rake::Task, "default").enhance { fail }
392
- ARGV.clear
393
- ARGV << '-f' << '-s' << '--rakelib=""'
394
- assert_raises(SystemExit) {
395
- _, err = capture_io { @app.run }
396
- assert_match(/see full trace/, err)
397
+ setup_command_line('-f', '-s', '--rakelib=""')
398
+ _, err = capture_io {
399
+ assert_raises(SystemExit){ @app.run }
397
400
  }
401
+ assert_match(/see full trace/i, err)
398
402
  ensure
399
403
  ARGV.clear
400
404
  end
401
405
 
402
406
  def test_bad_run_with_trace
403
407
  @app.intern(Rake::Task, "default").enhance { fail }
404
- ARGV.clear
405
- ARGV << '-f' << '-s' << '-t'
406
- assert_raises(SystemExit) {
407
- _, err = capture_io { @app.run }
408
- refute_match(/see full trace/, err)
408
+ setup_command_line('-f', '-s', '-t')
409
+ _, err = capture_io {
410
+ assert_raises(SystemExit) { @app.run }
409
411
  }
412
+ refute_match(/see full trace/i, err)
410
413
  ensure
411
414
  ARGV.clear
412
415
  end
413
416
 
414
417
  def test_bad_run_with_backtrace
415
418
  @app.intern(Rake::Task, "default").enhance { fail }
419
+ setup_command_line('-f', '-s', '--backtrace')
420
+ _, err = capture_io {
421
+ assert_raises(SystemExit) {
422
+ @app.run
423
+ }
424
+ }
425
+ refute_match(/see full trace/, err)
426
+ ensure
416
427
  ARGV.clear
417
- ARGV << '-f' << '-s' << '--backtrace'
418
- assert_raises(SystemExit) {
419
- _, err = capture_io { @app.run }
420
- refute_match(/see full trace/, err)
428
+ end
429
+
430
+ CustomError = Class.new(RuntimeError)
431
+
432
+ def test_bad_run_includes_exception_name
433
+ @app.intern(Rake::Task, "default").enhance {
434
+ raise CustomError, "intentional"
435
+ }
436
+ setup_command_line('-f', '-s')
437
+ _, err = capture_io {
438
+ assert_raises(SystemExit) {
439
+ @app.run
440
+ }
421
441
  }
442
+ assert_match(/CustomError: intentional/, err)
443
+ end
444
+
445
+ def test_rake_error_excludes_exception_name
446
+ @app.intern(Rake::Task, "default").enhance {
447
+ fail "intentional"
448
+ }
449
+ setup_command_line('-f', '-s')
450
+ _, err = capture_io {
451
+ assert_raises(SystemExit) {
452
+ @app.run
453
+ }
454
+ }
455
+ refute_match(/RuntimeError/, err)
456
+ assert_match(/intentional/, err)
457
+ end
458
+
459
+ def cause_supported?
460
+ ex = StandardError.new
461
+ ex.respond_to?(:cause)
462
+ end
463
+
464
+ def test_printing_original_exception_cause
465
+ custom_error = Class.new(StandardError)
466
+ @app.intern(Rake::Task, "default").enhance {
467
+ begin
468
+ raise custom_error, "Original Error"
469
+ rescue custom_error
470
+ raise custom_error, "Secondary Error"
471
+ end
472
+ }
473
+ setup_command_line('-f', '-s')
474
+ _ ,err = capture_io {
475
+ assert_raises(SystemExit) {
476
+ @app.run
477
+ }
478
+ }
479
+ if cause_supported?
480
+ assert_match(/Original Error/, err)
481
+ end
482
+ assert_match(/Secondary Error/, err)
422
483
  ensure
423
484
  ARGV.clear
424
485
  end
425
486
 
426
487
  def test_run_with_bad_options
427
488
  @app.intern(Rake::Task, "default").enhance { fail }
428
- ARGV.clear
429
- ARGV << '-f' << '-s' << '--xyzzy'
489
+ setup_command_line('-f', '-s', '--xyzzy')
430
490
  assert_raises(SystemExit) {
431
491
  capture_io { @app.run }
432
492
  }
@@ -500,14 +560,12 @@ class TestRakeApplication < Rake::TestCase
500
560
 
501
561
  loader.instance_variable_set :@load_called, false
502
562
  def loader.load arg
503
- raise 'called more than once' if @load_called
504
563
  raise ArgumentError, arg unless arg == 'x.dummy'
505
564
  @load_called = true
506
565
  end
507
566
 
508
567
  loader.instance_variable_set :@make_dummy_called, false
509
568
  def loader.make_dummy
510
- raise 'called more than once' if @make_dummy_called
511
569
  @make_dummy_called = true
512
570
  end
513
571
 
@@ -111,14 +111,23 @@ class TestRakeApplicationOptions < Rake::TestCase
111
111
  end
112
112
 
113
113
  def test_jobs
114
+ flags([]) do |opts|
115
+ assert_nil opts.thread_pool_size
116
+ end
117
+ flags(['--jobs', '0'], ['-j', '0']) do |opts|
118
+ assert_equal 0, opts.thread_pool_size
119
+ end
120
+ flags(['--jobs', '1'], ['-j', '1']) do |opts|
121
+ assert_equal 0, opts.thread_pool_size
122
+ end
114
123
  flags(['--jobs', '4'], ['-j', '4']) do |opts|
115
- assert_equal 4, opts.thread_pool_size
124
+ assert_equal 3, opts.thread_pool_size
116
125
  end
117
126
  flags(['--jobs', 'asdas'], ['-j', 'asdas']) do |opts|
118
- assert_equal 2, opts.thread_pool_size
127
+ assert_equal Rake.suggested_thread_count-1, opts.thread_pool_size
119
128
  end
120
129
  flags('--jobs', '-j') do |opts|
121
- assert_equal 2, opts.thread_pool_size
130
+ assert opts.thread_pool_size > 1_000_000, "thread pool size should be huge (was #{opts.thread_pool_size})"
122
131
  end
123
132
  end
124
133
 
@@ -449,7 +458,7 @@ class TestRakeApplicationOptions < Rake::TestCase
449
458
  end
450
459
  @app.instance_eval do
451
460
  handle_options
452
- collect_tasks
461
+ collect_command_line_tasks
453
462
  end
454
463
  @tasks = @app.top_level_tasks
455
464
  @app.options
@@ -11,7 +11,9 @@ class TestBacktraceSuppression < Rake::TestCase
11
11
  end
12
12
 
13
13
  def test_system_dir_suppressed
14
- path = RbConfig::CONFIG['rubylibprefix']
14
+ path = File.expand_path(RbConfig::CONFIG['rubylibprefix'])
15
+ skip if path.nil?
16
+
15
17
  paths = [path + ":12"]
16
18
 
17
19
  actual = Rake::Backtrace.collapse(paths)
@@ -20,7 +22,9 @@ class TestBacktraceSuppression < Rake::TestCase
20
22
  end
21
23
 
22
24
  def test_near_system_dir_isnt_suppressed
23
- path = RbConfig::CONFIG['rubylibprefix']
25
+ path = File.expand_path(RbConfig::CONFIG['rubylibprefix'])
26
+ skip if path.nil?
27
+
24
28
  paths = [" " + path + ":12"]
25
29
 
26
30
  actual = Rake::Backtrace.collapse(paths)
@@ -15,7 +15,7 @@ class TestRakeClean < Rake::TestCase
15
15
  file_name = create_undeletable_file
16
16
 
17
17
  out, _ = capture_io do
18
- Rake::Cleaner.cleanup(file_name, verbose: false)
18
+ Rake::Cleaner.cleanup(file_name, :verbose => false)
19
19
  end
20
20
  assert_match(/failed to remove/i, out)
21
21
 
@@ -40,7 +40,7 @@ class TestRakeClean < Rake::TestCase
40
40
  file_name = File.join(dir_name, "deleteme")
41
41
  FileUtils.chmod(0777, dir_name)
42
42
  FileUtils.chmod(0777, file_name)
43
- Rake::Cleaner.cleanup(file_name, verbose: false)
44
- Rake::Cleaner.cleanup(dir_name, verbose: false)
43
+ Rake::Cleaner.cleanup(file_name, :verbose => false)
44
+ Rake::Cleaner.cleanup(dir_name, :verbose => false)
45
45
  end
46
46
  end
@@ -0,0 +1,42 @@
1
+ require_relative 'helper'
2
+
3
+ class TestRakeCpuCounter < Rake::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @cpu_counter = Rake::CpuCounter.new
9
+ end
10
+
11
+ def test_in_path_command
12
+ with_ruby_in_path do |ruby|
13
+ assert_equal ruby, @cpu_counter.in_path_command(ruby)
14
+ end
15
+ rescue Errno::ENOENT => e
16
+ raise unless e.message =~ /\bwhich\b/
17
+
18
+ skip 'cannot find which for this test'
19
+ end
20
+
21
+ def test_run
22
+ with_ruby_in_path do |ruby|
23
+ assert_equal 7, @cpu_counter.run(ruby, '-e', 'puts 3 + 4')
24
+ end
25
+ end
26
+
27
+ def with_ruby_in_path
28
+ ruby = File.basename Gem.ruby
29
+ ruby_dir = File.dirname Gem.ruby
30
+
31
+ begin
32
+ orig_path, ENV['PATH'] =
33
+ ENV['PATH'], [ruby_dir, *ENV['PATH']].join(File::PATH_SEPARATOR)
34
+
35
+ yield ruby
36
+ ensure
37
+ ENV['PATH'] = orig_path
38
+ end
39
+ end
40
+
41
+ end
42
+
@@ -98,6 +98,16 @@ class TestRakeFileTask < Rake::TestCase
98
98
  assert @ran
99
99
  end
100
100
 
101
+ def test_source_is_first_prerequisite
102
+ t = file :f => ["preqA", "preqB"]
103
+ assert_equal "preqA", t.source
104
+ end
105
+
106
+ def test_sources_is_all_prerequisites
107
+ t = file :f => ["preqA", "preqB"]
108
+ assert_equal ["preqA", "preqB"], t.sources
109
+ end
110
+
101
111
  # I have currently disabled this test. I'm not convinced that
102
112
  # deleting the file target on failure is always the proper thing to
103
113
  # do. I'm willing to hear input on this topic.
@@ -268,6 +268,14 @@ class TestRakeFunctional < Rake::TestCase
268
268
  assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
269
269
  end
270
270
 
271
+ def test_regenerate_imports
272
+ rakefile_regenerate_imports
273
+
274
+ rake
275
+
276
+ assert_match(/^INITIAL\s+^REGENERATED$/, @out)
277
+ end
278
+
271
279
  def test_rules_chaining_to_file_task
272
280
  rakefile_chains
273
281
 
@@ -368,6 +376,14 @@ class TestRakeFunctional < Rake::TestCase
368
376
  assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
369
377
  end
370
378
 
379
+ def test_test_task_descriptions
380
+ rakefile_test_task
381
+
382
+ rake "-T"
383
+
384
+ assert_match(/custom test task description/, @out)
385
+ end
386
+
371
387
  def test_comment_before_task_acts_like_desc
372
388
  rakefile_comments
373
389
 
@@ -414,7 +430,7 @@ class TestRakeFunctional < Rake::TestCase
414
430
  end
415
431
 
416
432
  def can_detect_signals?
417
- system "ruby -e 'Process.kill \"TERM\", $$'"
433
+ system RUBY, '-e', 'Process.kill "TERM", $$'
418
434
  status = $?
419
435
  if @verbose
420
436
  puts " SIG status = #{$?.inspect}"
@@ -156,8 +156,8 @@ class TestRakePathMap < Rake::TestCase
156
156
  "src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class"))
157
157
  assert_equal(
158
158
  "src_work/bin/org/onstepback/proj/A.class",
159
- "src_work/src/org/onstepback/proj/A.java"
160
- .pathmap('%{\bsrc\b,bin}X.class'))
159
+ "src_work/src/org/onstepback/proj/A.java".
160
+ pathmap('%{\bsrc\b,bin}X.class'))
161
161
  assert_equal(
162
162
  ".depends.bak",
163
163
  ".depends".pathmap("%X.bak"))
@@ -359,4 +359,30 @@ class TestRakeRules < Rake::TestCase
359
359
  Task[OBJFILE].invoke('arg')
360
360
  end
361
361
 
362
+ def test_rule_with_method_prereq
363
+ create_file(".foo")
364
+ obj = Object.new
365
+ def obj.find_prereq
366
+ ".foo"
367
+ end
368
+ rule '.o' => obj.method(:find_prereq) do |t|
369
+ @runs << "#{t.name} - #{t.source}"
370
+ end
371
+ Task[OBJFILE].invoke
372
+ assert_equal ["#{OBJFILE} - .foo"], @runs
373
+ end
374
+
375
+ def test_rule_with_one_arg_method_prereq
376
+ create_file(SRCFILE)
377
+ obj = Object.new
378
+ def obj.find_prereq(task_name)
379
+ task_name.ext(".c")
380
+ end
381
+ rule '.o' => obj.method(:find_prereq) do |t|
382
+ @runs << "#{t.name} - #{t.source}"
383
+ end
384
+ Task[OBJFILE].invoke
385
+ assert_equal ["#{OBJFILE} - abc.c"], @runs
386
+ end
387
+
362
388
  end
@@ -332,6 +332,17 @@ class TestRakeTask < Rake::TestCase
332
332
  assert_equal "Revision 1.2.3", t.comment
333
333
  end
334
334
 
335
+ def test_comments_do_not_set
336
+ t = task(:t, :name, :rev)
337
+ assert_equal nil, t.comment
338
+ end
339
+
340
+ def test_comments_is_nil
341
+ t = task(:t, :name, :rev)
342
+ t.comment = nil
343
+ assert_equal nil, t.comment
344
+ end
345
+
335
346
  def test_extended_comments
336
347
  desc %{
337
348
  This is a comment.
@@ -373,4 +384,9 @@ class TestRakeTask < Rake::TestCase
373
384
  task(:t)
374
385
  assert_equal "line one / line two", t.comment
375
386
  end
387
+
388
+ def test_source_is_first_prerequisite
389
+ t = task :t => ["preqA", "preqB"]
390
+ assert_equal "preqA", t.source
391
+ end
376
392
  end