rake 10.0.4 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/doc/command_line_usage.rdoc +1 -1
  4. data/doc/rakefile.rdoc +27 -13
  5. data/doc/release_notes/rake-10.1.0.rdoc +61 -0
  6. data/install.rb +5 -15
  7. data/lib/rake/alt_system.rb +3 -4
  8. data/lib/rake/application.rb +115 -68
  9. data/lib/rake/backtrace.rb +9 -8
  10. data/lib/rake/clean.rb +27 -4
  11. data/lib/rake/contrib/ftptools.rb +6 -18
  12. data/lib/rake/contrib/sys.rb +2 -1
  13. data/lib/rake/dsl_definition.rb +2 -1
  14. data/lib/rake/ext/core.rb +2 -1
  15. data/lib/rake/ext/string.rb +1 -3
  16. data/lib/rake/file_list.rb +24 -18
  17. data/lib/rake/file_task.rb +1 -2
  18. data/lib/rake/file_utils.rb +9 -7
  19. data/lib/rake/file_utils_ext.rb +2 -1
  20. data/lib/rake/gempackagetask.rb +2 -1
  21. data/lib/rake/invocation_chain.rb +24 -18
  22. data/lib/rake/linked_list.rb +103 -0
  23. data/lib/rake/packagetask.rb +11 -6
  24. data/lib/rake/pseudo_status.rb +5 -0
  25. data/lib/rake/rdoctask.rb +2 -1
  26. data/lib/rake/ruby182_test_unit_fix.rb +4 -2
  27. data/lib/rake/runtest.rb +2 -2
  28. data/lib/rake/scope.rb +42 -0
  29. data/lib/rake/task.rb +47 -37
  30. data/lib/rake/task_arguments.rb +13 -2
  31. data/lib/rake/task_manager.rb +25 -24
  32. data/lib/rake/tasklib.rb +1 -1
  33. data/lib/rake/testtask.rb +10 -7
  34. data/lib/rake/thread_history_display.rb +1 -1
  35. data/lib/rake/thread_pool.rb +10 -4
  36. data/lib/rake/version.rb +3 -7
  37. data/lib/rake/win32.rb +3 -2
  38. data/lib/rake.rb +2 -0
  39. data/test/helper.rb +36 -470
  40. data/test/support/rakefile_definitions.rb +444 -0
  41. data/test/support/ruby_runner.rb +33 -0
  42. data/test/test_rake_application.rb +14 -12
  43. data/test/test_rake_application_options.rb +7 -5
  44. data/test/test_rake_backtrace.rb +38 -14
  45. data/test/test_rake_clean.rb +36 -4
  46. data/test/test_rake_definitions.rb +2 -3
  47. data/test/test_rake_file_creation_task.rb +2 -2
  48. data/test/test_rake_file_list.rb +23 -24
  49. data/test/test_rake_file_task.rb +4 -4
  50. data/test/test_rake_file_utils.rb +6 -2
  51. data/test/test_rake_ftp_file.rb +28 -13
  52. data/test/test_rake_functional.rb +6 -36
  53. data/test/test_rake_invocation_chain.rb +15 -3
  54. data/test/test_rake_linked_list.rb +84 -0
  55. data/test/test_rake_makefile_loader.rb +3 -1
  56. data/test/test_rake_multi_task.rb +2 -3
  57. data/test/test_rake_name_space.rb +1 -1
  58. data/test/test_rake_path_map.rb +23 -12
  59. data/test/test_rake_rake_test_loader.rb +2 -3
  60. data/test/test_rake_reduce_compat.rb +2 -6
  61. data/test/test_rake_rules.rb +47 -12
  62. data/test/test_rake_scope.rb +44 -0
  63. data/test/test_rake_task.rb +47 -11
  64. data/test/test_rake_task_arguments.rb +35 -2
  65. data/test/test_rake_task_manager.rb +16 -15
  66. data/test/test_rake_task_with_arguments.rb +2 -2
  67. data/test/test_rake_test_task.rb +1 -2
  68. data/test/test_rake_thread_pool.rb +36 -16
  69. data/test/test_thread_history_display.rb +16 -6
  70. data/test/test_trace_output.rb +2 -0
  71. metadata +10 -2
@@ -102,7 +102,7 @@ class TestRakeRules < Rake::TestCase
102
102
  verbose(false) do
103
103
 
104
104
  create_file(".foo")
105
- rule '.o' => lambda{".foo"} do |t|
105
+ rule '.o' => lambda { ".foo" } do |t|
106
106
  @runs << "#{t.name} - #{t.source}"
107
107
  end
108
108
  Task[OBJFILE].invoke
@@ -113,7 +113,7 @@ class TestRakeRules < Rake::TestCase
113
113
  def test_file_names_containing_percent_can_be_wrapped_in_lambda
114
114
  verbose(false) do
115
115
  create_file("foo%x")
116
- rule '.o' => lambda{"foo%x"} do |t|
116
+ rule '.o' => lambda { "foo%x" } do |t|
117
117
  @runs << "#{t.name} - #{t.source}"
118
118
  end
119
119
  Task[OBJFILE].invoke
@@ -186,7 +186,7 @@ class TestRakeRules < Rake::TestCase
186
186
 
187
187
  def test_rule_with_two_sources_runs_if_both_sources_are_present
188
188
  create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
189
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
189
+ rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do
190
190
  @runs << :RULE
191
191
  end
192
192
  Task[OBJFILE].invoke
@@ -196,7 +196,7 @@ class TestRakeRules < Rake::TestCase
196
196
  def test_rule_with_two_sources_but_one_missing_does_not_run
197
197
  create_timed_files(OBJFILE, SRCFILE)
198
198
  delete_file(SRCFILE2)
199
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
199
+ rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do
200
200
  @runs << :RULE
201
201
  end
202
202
  Task[OBJFILE].invoke
@@ -222,10 +222,10 @@ class TestRakeRules < Rake::TestCase
222
222
  def test_second_rule_runs_when_first_rule_doesnt
223
223
  create_timed_files(OBJFILE, SRCFILE)
224
224
  delete_file(SRCFILE2)
225
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
225
+ rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do
226
226
  @runs << :RULE1
227
227
  end
228
- rule OBJFILE => [lambda{SRCFILE}] do
228
+ rule OBJFILE => [lambda { SRCFILE }] do
229
229
  @runs << :RULE2
230
230
  end
231
231
  Task[OBJFILE].invoke
@@ -234,10 +234,10 @@ class TestRakeRules < Rake::TestCase
234
234
 
235
235
  def test_second_rule_doest_run_if_first_triggers
236
236
  create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
237
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
237
+ rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do
238
238
  @runs << :RULE1
239
239
  end
240
- rule OBJFILE => [lambda{SRCFILE}] do
240
+ rule OBJFILE => [lambda { SRCFILE }] do
241
241
  @runs << :RULE2
242
242
  end
243
243
  Task[OBJFILE].invoke
@@ -246,10 +246,10 @@ class TestRakeRules < Rake::TestCase
246
246
 
247
247
  def test_second_rule_doest_run_if_first_triggers_with_reversed_rules
248
248
  create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
249
- rule OBJFILE => [lambda{SRCFILE}] do
249
+ rule OBJFILE => [lambda { SRCFILE }] do
250
250
  @runs << :RULE1
251
251
  end
252
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
252
+ rule OBJFILE => [lambda { SRCFILE }, lambda { SRCFILE2 }] do
253
253
  @runs << :RULE2
254
254
  end
255
255
  Task[OBJFILE].invoke
@@ -319,9 +319,44 @@ class TestRakeRules < Rake::TestCase
319
319
  end
320
320
 
321
321
  def test_rules_with_bad_dependents_will_fail
322
- rule "a" => [ 1 ] do |t| puts t.name end
322
+ rule "a" => [1] do |t| puts t.name end
323
323
  assert_raises(RuntimeError) do Task['a'].invoke end
324
324
  end
325
325
 
326
- end
326
+ def test_string_rule_with_args
327
+ delete_file(OBJFILE)
328
+ create_file(SRCFILE)
329
+ rule '.o', [:a] => SRCFILE do |t, args|
330
+ assert_equal 'arg', args.a
331
+ end
332
+ Task[OBJFILE].invoke('arg')
333
+ end
327
334
 
335
+ def test_regex_rule_with_args
336
+ delete_file(OBJFILE)
337
+ create_file(SRCFILE)
338
+ rule(/.o$/, [:a] => SRCFILE) do |t, args|
339
+ assert_equal 'arg', args.a
340
+ end
341
+ Task[OBJFILE].invoke('arg')
342
+ end
343
+
344
+ def test_string_rule_with_args_and_lambda_prereq
345
+ delete_file(OBJFILE)
346
+ create_file(SRCFILE)
347
+ rule '.o', [:a] => [lambda{SRCFILE}]do |t, args|
348
+ assert_equal 'arg', args.a
349
+ end
350
+ Task[OBJFILE].invoke('arg')
351
+ end
352
+
353
+ def test_regex_rule_with_args_and_lambda_prereq
354
+ delete_file(OBJFILE)
355
+ create_file(SRCFILE)
356
+ rule(/.o$/, [:a] => [lambda{SRCFILE}]) do |t, args|
357
+ assert_equal 'arg', args.a
358
+ end
359
+ Task[OBJFILE].invoke('arg')
360
+ end
361
+
362
+ end
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeScope < Rake::TestCase
4
+ include Rake
5
+
6
+ def test_path_against_empty_scope
7
+ scope = Scope.make
8
+ assert_equal scope, Scope::EMPTY
9
+ assert_equal scope.path, ""
10
+ end
11
+
12
+ def test_path_against_one_element
13
+ scope = Scope.make(:one)
14
+ assert_equal "one", scope.path
15
+ end
16
+
17
+ def test_path_against_two_elements
18
+ scope = Scope.make(:inner, :outer)
19
+ assert_equal "outer:inner", scope.path
20
+ end
21
+
22
+ def test_path_with_task_name
23
+ scope = Scope.make(:inner, :outer)
24
+ assert_equal "outer:inner:task", scope.path_with_task_name("task")
25
+ end
26
+
27
+ def test_path_with_task_name_against_empty_scope
28
+ scope = Scope.make
29
+ assert_equal "task", scope.path_with_task_name("task")
30
+ end
31
+
32
+ def test_conj_against_two_elements
33
+ scope = Scope.make.conj("B").conj("A")
34
+ assert_equal Scope.make("A", "B"), scope
35
+ end
36
+
37
+ def test_trim
38
+ scope = Scope.make("A", "B")
39
+ assert_equal scope, scope.trim(0)
40
+ assert_equal scope.tail, scope.trim(1)
41
+ assert_equal scope.tail.tail, scope.trim(2)
42
+ assert_equal scope.tail.tail, scope.trim(3)
43
+ end
44
+ end
@@ -156,8 +156,8 @@ class TestRakeTask < Rake::TestCase
156
156
  def test_multi_invocations
157
157
  runs = []
158
158
  p = proc do |t| runs << t.name end
159
- task({:t1=>[:t2,:t3]}, &p)
160
- task({:t2=>[:t3]}, &p)
159
+ task({ :t1 => [:t2, :t3] }, &p)
160
+ task({ :t2 => [:t3] }, &p)
161
161
  task(:t3, &p)
162
162
  Task[:t1].invoke
163
163
  assert_equal ["t1", "t2", "t3"], runs.sort
@@ -166,7 +166,7 @@ class TestRakeTask < Rake::TestCase
166
166
  def test_task_list
167
167
  task :t2
168
168
  task :t1 => [:t2]
169
- assert_equal ["t1", "t2"], Task.tasks.collect {|t| t.name}
169
+ assert_equal ["t1", "t2"], Task.tasks.map { |t| t.name }
170
170
  end
171
171
 
172
172
  def test_task_gives_name_on_to_s
@@ -271,15 +271,15 @@ class TestRakeTask < Rake::TestCase
271
271
 
272
272
  t_a = task(:a) do |t|
273
273
  sleep 0.02
274
- mx.synchronize{ result << t.name }
274
+ mx.synchronize { result << t.name }
275
275
  end
276
276
 
277
277
  t_b = task(:b) do |t|
278
- mx.synchronize{ result << t.name }
278
+ mx.synchronize { result << t.name }
279
279
  end
280
280
 
281
- t_c = task(:c => [:a,:b]) do |t|
282
- mx.synchronize{ result << t.name }
281
+ t_c = task(:c => [:a, :b]) do |t|
282
+ mx.synchronize { result << t.name }
283
283
  end
284
284
 
285
285
  t_c.invoke
@@ -307,6 +307,30 @@ class TestRakeTask < Rake::TestCase
307
307
  assert_match(/pre-requisites:\s*--t[23]/, out)
308
308
  end
309
309
 
310
+ # NOTE: Rail-ties uses comment=.
311
+ def test_comment_setting
312
+ t = task(:t, :name, :rev)
313
+ t.comment = "A Comment"
314
+ assert_equal "A Comment", t.comment
315
+ end
316
+
317
+ def test_comments_with_sentences
318
+ desc "Comment 1. Comment 2."
319
+ t = task(:t, :name, :rev)
320
+ assert_equal "Comment 1", t.comment
321
+ end
322
+
323
+ def test_comments_with_tabbed_sentences
324
+ desc "Comment 1.\tComment 2."
325
+ t = task(:t, :name, :rev)
326
+ assert_equal "Comment 1", t.comment
327
+ end
328
+
329
+ def test_comments_with_decimal_points
330
+ desc "Revision 1.2.3."
331
+ t = task(:t, :name, :rev)
332
+ assert_equal "Revision 1.2.3", t.comment
333
+ end
310
334
 
311
335
  def test_extended_comments
312
336
  desc %{
@@ -318,7 +342,7 @@ class TestRakeTask < Rake::TestCase
318
342
  }
319
343
  t = task(:t, :name, :rev)
320
344
  assert_equal "[name,rev]", t.arg_description
321
- assert_equal "This is a comment.", t.comment
345
+ assert_equal "This is a comment", t.comment
322
346
  assert_match(/^\s*name -- Name/, t.full_comment)
323
347
  assert_match(/^\s*rev -- Software/, t.full_comment)
324
348
  assert_match(/\A\s*This is a comment\.$/, t.full_comment)
@@ -332,9 +356,21 @@ class TestRakeTask < Rake::TestCase
332
356
  assert_equal "line one / line two", t.comment
333
357
  end
334
358
 
335
- def test_settable_comments
359
+ def test_duplicate_comments
360
+ desc "line one"
336
361
  t = task(:t)
337
- t.comment = "HI"
338
- assert_equal "HI", t.comment
362
+ desc "line one"
363
+ task(:t)
364
+ assert_equal "line one", t.comment
365
+ end
366
+
367
+ def test_interspersed_duplicate_comments
368
+ desc "line one"
369
+ t = task(:t)
370
+ desc "line two"
371
+ task(:t)
372
+ desc "line one"
373
+ task(:t)
374
+ assert_equal "line one / line two", t.comment
339
375
  end
340
376
  end
@@ -26,8 +26,8 @@ class TestRakeTaskArguments < Rake::TestCase
26
26
  end
27
27
 
28
28
  def test_enumerable_behavior
29
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2 ,3])
30
- assert_equal [10, 20, 30], ta.collect { |k,v| v * 10 }.sort
29
+ ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
30
+ assert_equal [10, 20, 30], ta.map { |k, v| v * 10 }.sort
31
31
  end
32
32
 
33
33
  def test_named_args
@@ -85,4 +85,37 @@ class TestRakeTaskArguments < Rake::TestCase
85
85
  ta.with_defaults({ "cc" => "default_val" })
86
86
  assert_nil ta[:cc]
87
87
  end
88
+
89
+ def test_all_and_extra_arguments_without_named_arguments
90
+ app = Rake::Application.new
91
+ _, args = app.parse_task_string("task[1,two,more]")
92
+ ta = Rake::TaskArguments.new([], args)
93
+ assert_equal [], ta.names
94
+ assert_equal ['1', 'two', 'more'], ta.to_a
95
+ assert_equal ['1', 'two', 'more'], ta.extras
96
+ end
97
+
98
+ def test_all_and_extra_arguments_with_named_arguments
99
+ app = Rake::Application.new
100
+ _, args = app.parse_task_string("task[1,two,more,still more]")
101
+ ta = Rake::TaskArguments.new([:first, :second], args)
102
+ assert_equal [:first, :second], ta.names
103
+ assert_equal "1", ta[:first]
104
+ assert_equal "two", ta[:second]
105
+ assert_equal ['1', 'two', 'more', 'still more'], ta.to_a
106
+ assert_equal ['more', 'still more'], ta.extras
107
+ end
108
+
109
+ def test_extra_args_with_less_than_named_arguments
110
+ app = Rake::Application.new
111
+ _, args = app.parse_task_string("task[1,two]")
112
+ ta = Rake::TaskArguments.new([:first, :second, :third], args)
113
+ assert_equal [:first, :second, :third], ta.names
114
+ assert_equal "1", ta[:first]
115
+ assert_equal "two", ta[:second]
116
+ assert_equal nil, ta[:third]
117
+ assert_equal ['1', 'two'], ta.to_a
118
+ assert_equal [], ta.extras
119
+ end
120
+
88
121
  end
@@ -37,7 +37,7 @@ class TestRakeTaskManager < Rake::TestCase
37
37
  t = @tm.define_task(Rake::Task, :t)
38
38
  assert_equal "x:t", t.name
39
39
  end
40
- assert_equal ["x:t"], @tm.tasks.collect { |t| t.name }
40
+ assert_equal ["x:t"], @tm.tasks.map { |t| t.name }
41
41
  end
42
42
 
43
43
  def test_anonymous_namespace
@@ -55,7 +55,7 @@ class TestRakeTaskManager < Rake::TestCase
55
55
  assert_equal "fn", t.name
56
56
  end
57
57
 
58
- assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
58
+ assert_equal ["fn"], @tm.tasks.map { |t| t.name }
59
59
  end
60
60
 
61
61
  def test_namespace_yields_same_namespace_as_returned
@@ -93,7 +93,7 @@ class TestRakeTaskManager < Rake::TestCase
93
93
  bb = @tm.define_task(Rake::Task, :bb)
94
94
  bot_z = @tm.define_task(Rake::Task, :z)
95
95
 
96
- assert_equal ["a", "b"], @tm.current_scope
96
+ assert_equal Rake::Scope.make("b", "a"), @tm.current_scope
97
97
 
98
98
  assert_equal bb, @tm["a:b:bb"]
99
99
  assert_equal aa, @tm["a:aa"]
@@ -101,10 +101,11 @@ class TestRakeTaskManager < Rake::TestCase
101
101
  assert_equal bot_z, @tm["z"]
102
102
  assert_equal mid_z, @tm["^z"]
103
103
  assert_equal top_z, @tm["^^z"]
104
+ assert_equal top_z, @tm["^^^z"] # Over the top
104
105
  assert_equal top_z, @tm["rake:z"]
105
106
  end
106
107
 
107
- assert_equal ["a"], @tm.current_scope
108
+ assert_equal Rake::Scope.make("a"), @tm.current_scope
108
109
 
109
110
  assert_equal bb, @tm["a:b:bb"]
110
111
  assert_equal aa, @tm["a:aa"]
@@ -113,18 +114,19 @@ class TestRakeTaskManager < Rake::TestCase
113
114
  assert_equal aa, @tm["aa"]
114
115
  assert_equal mid_z, @tm["z"]
115
116
  assert_equal top_z, @tm["^z"]
117
+ assert_equal top_z, @tm["^^z"] # Over the top
116
118
  assert_equal top_z, @tm["rake:z"]
117
119
  end
118
120
 
119
- assert_equal [], @tm.current_scope
121
+ assert_equal Rake::Scope.make, @tm.current_scope
120
122
 
121
- assert_equal [], xx.scope
122
- assert_equal ['a'], aa.scope
123
- assert_equal ['a', 'b'], bb.scope
123
+ assert_equal Rake::Scope.make, xx.scope
124
+ assert_equal Rake::Scope.make('a'), aa.scope
125
+ assert_equal Rake::Scope.make('b', 'a'), bb.scope
124
126
  end
125
127
 
126
128
  def test_lookup_with_explicit_scopes
127
- t1, t2, t3, s = (0...4).collect { nil }
129
+ t1, t2, t3, s = (0...4).map { nil }
128
130
  t1 = @tm.define_task(Rake::Task, :t)
129
131
  @tm.in_namespace("a") do
130
132
  t2 = @tm.define_task(Rake::Task, :t)
@@ -133,11 +135,11 @@ class TestRakeTaskManager < Rake::TestCase
133
135
  t3 = @tm.define_task(Rake::Task, :t)
134
136
  end
135
137
  end
136
- assert_equal t1, @tm[:t, []]
137
- assert_equal t2, @tm[:t, ["a"]]
138
- assert_equal t3, @tm[:t, ["a", "b"]]
139
- assert_equal s, @tm[:s, ["a", "b"]]
140
- assert_equal s, @tm[:s, ["a"]]
138
+ assert_equal t1, @tm[:t, Rake::Scope.make]
139
+ assert_equal t2, @tm[:t, Rake::Scope.make("a")]
140
+ assert_equal t3, @tm[:t, Rake::Scope.make("b", "a")]
141
+ assert_equal s, @tm[:s, Rake::Scope.make("b", "a")]
142
+ assert_equal s, @tm[:s, Rake::Scope.make("a")]
141
143
  end
142
144
 
143
145
  def test_correctly_scoped_prerequisites_are_invoked
@@ -154,4 +156,3 @@ class TestRakeTaskManager < Rake::TestCase
154
156
  end
155
157
 
156
158
  end
157
-
@@ -81,7 +81,7 @@ class TestRakeTaskWithArguments < Rake::TestCase
81
81
 
82
82
  def test_arguments_are_passed_to_block
83
83
  t = task(:t, :a, :b) { |tt, args|
84
- assert_equal( { :a => 1, :b => 2 }, args.to_hash )
84
+ assert_equal({ :a => 1, :b => 2 }, args.to_hash)
85
85
  }
86
86
  t.invoke(1, 2)
87
87
  end
@@ -121,7 +121,7 @@ class TestRakeTaskWithArguments < Rake::TestCase
121
121
  assert_equal "T", t.comment
122
122
  assert_equal "[a,b]", t.arg_description
123
123
  assert_equal "tt[a,b]", t.name_with_args
124
- assert_equal [:a, :b],t.arg_names
124
+ assert_equal [:a, :b], t.arg_names
125
125
  end
126
126
 
127
127
  def test_named_args_are_passed_to_prereqs
@@ -28,7 +28,7 @@ class TestRakeTestTask < Rake::TestCase
28
28
  assert Task.task_defined?(:example)
29
29
  end
30
30
 
31
- def test_file_list_ENV_TEST
31
+ def test_file_list_env_test
32
32
  ENV['TEST'] = 'testfile.rb'
33
33
  tt = Rake::TestTask.new do |t|
34
34
  t.pattern = '*'
@@ -117,4 +117,3 @@ class TestRakeTestTask < Rake::TestCase
117
117
  end
118
118
 
119
119
  end
120
-
@@ -7,21 +7,28 @@ class TestRakeTestThreadPool < Rake::TestCase
7
7
 
8
8
  def test_pool_executes_in_current_thread_for_zero_threads
9
9
  pool = ThreadPool.new(0)
10
- f = pool.future{Thread.current}
10
+ f = pool.future { Thread.current }
11
11
  pool.join
12
12
  assert_equal Thread.current, f.value
13
13
  end
14
14
 
15
15
  def test_pool_executes_in_other_thread_for_pool_of_size_one
16
16
  pool = ThreadPool.new(1)
17
- f = pool.future{Thread.current}
17
+ f = pool.future { Thread.current }
18
18
  pool.join
19
19
  refute_equal Thread.current, f.value
20
20
  end
21
21
 
22
22
  def test_pool_executes_in_two_other_threads_for_pool_of_size_two
23
23
  pool = ThreadPool.new(2)
24
- threads = 2.times.collect{ pool.future{ sleep 0.1; Thread.current } }.each{|f|f.value}
24
+ threads = 2.times.map {
25
+ pool.future {
26
+ sleep 0.1
27
+ Thread.current
28
+ }
29
+ }.each { |f|
30
+ f.value
31
+ }
25
32
 
26
33
  refute_equal threads[0], threads[1]
27
34
  refute_equal Thread.current, threads[0]
@@ -35,14 +42,14 @@ class TestRakeTestThreadPool < Rake::TestCase
35
42
  10.times.each do
36
43
  pool.future do
37
44
  sleep 0.02
38
- t_mutex.synchronize{ threads << Thread.current }
45
+ t_mutex.synchronize { threads << Thread.current }
39
46
  end
40
47
  end
41
48
  pool.join
42
49
  assert_equal 2, threads.count
43
50
  end
44
51
 
45
- def test_pool_future_does_NOT_duplicate_arguments
52
+ def test_pool_future_does_not_duplicate_arguments
46
53
  pool = ThreadPool.new(2)
47
54
  obj = Object.new
48
55
  captured = nil
@@ -67,7 +74,10 @@ class TestRakeTestThreadPool < Rake::TestCase
67
74
  }
68
75
 
69
76
  pool.join
70
- assert_equal true, pool.__send__(:__queue__).empty?, "queue should be empty"
77
+ assert_equal(
78
+ true,
79
+ pool.__send__(:__queue__).empty?,
80
+ "queue should be empty")
71
81
  end
72
82
 
73
83
  CustomError = Class.new(StandardError)
@@ -78,8 +88,8 @@ class TestRakeTestThreadPool < Rake::TestCase
78
88
  pool = ThreadPool.new(10)
79
89
 
80
90
  deep_exception_block = lambda do |count|
81
- raise CustomError if ( count < 1 )
82
- pool.future(count-1, &deep_exception_block).value
91
+ raise CustomError if count < 1
92
+ pool.future(count - 1, &deep_exception_block).value
83
93
  end
84
94
 
85
95
  assert_raises(CustomError) do
@@ -91,12 +101,22 @@ class TestRakeTestThreadPool < Rake::TestCase
91
101
  pool = ThreadPool.new(5)
92
102
 
93
103
  common_dependency_a = pool.future { sleep 0.2 }
94
- futures_a = 10.times.collect { pool.future{ common_dependency_a.value; sleep(rand() * 0.01) } }
104
+ futures_a = 10.times.map {
105
+ pool.future {
106
+ common_dependency_a.value
107
+ sleep(rand() * 0.01)
108
+ }
109
+ }
95
110
 
96
111
  common_dependency_b = pool.future { futures_a.each { |f| f.value } }
97
- futures_b = 10.times.collect { pool.future{ common_dependency_b.value; sleep(rand() * 0.01) } }
112
+ futures_b = 10.times.map {
113
+ pool.future {
114
+ common_dependency_b.value
115
+ sleep(rand() * 0.01)
116
+ }
117
+ }
98
118
 
99
- futures_b.each{|f|f.value}
119
+ futures_b.each { |f| f.value }
100
120
  pool.join
101
121
  end
102
122
 
@@ -107,15 +127,15 @@ class TestRakeTestThreadPool < Rake::TestCase
107
127
  b = 5
108
128
  c = 3
109
129
 
110
- result = a.times.collect do
130
+ result = a.times.map do
111
131
  pool.future do
112
- b.times.collect do
132
+ b.times.map do
113
133
  pool.future { sleep rand * 0.001; c }
114
- end.inject(0) { |m,f| m+f.value }
134
+ end.reduce(0) { |m, f| m + f.value }
115
135
  end
116
- end.inject(0) { |m,f| m+f.value }
136
+ end.reduce(0) { |m, f| m + f.value }
117
137
 
118
- assert_equal( (a*b*c), result )
138
+ assert_equal a * b * c, result
119
139
  pool.join
120
140
  end
121
141
 
@@ -5,7 +5,7 @@ require 'rake/thread_history_display'
5
5
  class TestThreadHistoryDisplay < Rake::TestCase
6
6
  def setup
7
7
  super
8
- @time = 1000000
8
+ @time = 1_000_000
9
9
  @stats = []
10
10
  @display = Rake::ThreadHistoryDisplay.new(@stats)
11
11
  end
@@ -60,24 +60,34 @@ class TestThreadHistoryDisplay < Rake::TestCase
60
60
  end
61
61
 
62
62
  def test_thread_deleted
63
- @stats << event(:thread_deleted, :deleted_thread => 123456, :thread_count => 12)
63
+ @stats << event(
64
+ :thread_deleted,
65
+ :deleted_thread => 123_456,
66
+ :thread_count => 12)
64
67
  out, _ = capture_io do
65
68
  @display.show
66
69
  end
67
- assert_match(/^ *1000000 +A +thread_deleted( +deleted_thread:B| +thread_count:12){2}$/, out)
70
+ assert_match(
71
+ /^ *1000000 +A +thread_deleted( +deleted_thread:B| +thread_count:12){2}$/,
72
+ out)
68
73
  end
69
74
 
70
75
  def test_thread_created
71
- @stats << event(:thread_created, :new_thread => 123456, :thread_count => 13)
76
+ @stats << event(
77
+ :thread_created,
78
+ :new_thread => 123_456,
79
+ :thread_count => 13)
72
80
  out, _ = capture_io do
73
81
  @display.show
74
82
  end
75
- assert_match(/^ *1000000 +A +thread_created( +new_thread:B| +thread_count:13){2}$/, out)
83
+ assert_match(
84
+ /^ *1000000 +A +thread_created( +new_thread:B| +thread_count:13){2}$/,
85
+ out)
76
86
  end
77
87
 
78
88
  private
79
89
 
80
- def event(type, data={})
90
+ def event(type, data = {})
81
91
  result = {
82
92
  :event => type,
83
93
  :time => @time / 1_000_000.0,
@@ -6,10 +6,12 @@ class TestTraceOutput < Rake::TestCase
6
6
 
7
7
  class PrintSpy
8
8
  attr_reader :result, :calls
9
+
9
10
  def initialize
10
11
  @result = ""
11
12
  @calls = 0
12
13
  end
14
+
13
15
  def print(string)
14
16
  @result << string
15
17
  @calls += 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.4
4
+ version: 10.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-25 00:00:00.000000000 Z
11
+ date: 2013-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -69,6 +69,7 @@ extra_rdoc_files:
69
69
  - doc/release_notes/rake-10.0.1.rdoc
70
70
  - doc/release_notes/rake-10.0.2.rdoc
71
71
  - doc/release_notes/rake-10.0.3.rdoc
72
+ - doc/release_notes/rake-10.1.0.rdoc
72
73
  files:
73
74
  - .gemtest
74
75
  - install.rb
@@ -105,6 +106,7 @@ files:
105
106
  - lib/rake/gempackagetask.rb
106
107
  - lib/rake/invocation_chain.rb
107
108
  - lib/rake/invocation_exception_mixin.rb
109
+ - lib/rake/linked_list.rb
108
110
  - lib/rake/loaders/makefile.rb
109
111
  - lib/rake/multi_task.rb
110
112
  - lib/rake/name_space.rb
@@ -120,6 +122,7 @@ files:
120
122
  - lib/rake/ruby182_test_unit_fix.rb
121
123
  - lib/rake/rule_recursion_overflow_error.rb
122
124
  - lib/rake/runtest.rb
125
+ - lib/rake/scope.rb
123
126
  - lib/rake/task.rb
124
127
  - lib/rake/task_argument_error.rb
125
128
  - lib/rake/task_arguments.rb
@@ -133,6 +136,8 @@ files:
133
136
  - lib/rake/win32.rb
134
137
  - test/file_creation.rb
135
138
  - test/helper.rb
139
+ - test/support/rakefile_definitions.rb
140
+ - test/support/ruby_runner.rb
136
141
  - test/test_private_reader.rb
137
142
  - test/test_rake.rb
138
143
  - test/test_rake_application.rb
@@ -152,6 +157,7 @@ files:
152
157
  - test/test_rake_ftp_file.rb
153
158
  - test/test_rake_functional.rb
154
159
  - test/test_rake_invocation_chain.rb
160
+ - test/test_rake_linked_list.rb
155
161
  - test/test_rake_makefile_loader.rb
156
162
  - test/test_rake_multi_task.rb
157
163
  - test/test_rake_name_space.rb
@@ -164,6 +170,7 @@ files:
164
170
  - test/test_rake_reduce_compat.rb
165
171
  - test/test_rake_require.rb
166
172
  - test/test_rake_rules.rb
173
+ - test/test_rake_scope.rb
167
174
  - test/test_rake_task.rb
168
175
  - test/test_rake_task_argument_parsing.rb
169
176
  - test/test_rake_task_arguments.rb
@@ -218,6 +225,7 @@ files:
218
225
  - doc/release_notes/rake-10.0.1.rdoc
219
226
  - doc/release_notes/rake-10.0.2.rdoc
220
227
  - doc/release_notes/rake-10.0.3.rdoc
228
+ - doc/release_notes/rake-10.1.0.rdoc
221
229
  homepage: http://rake.rubyforge.org
222
230
  licenses:
223
231
  - MIT