rake 0.9.3.beta.1 → 0.9.3.beta.2

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.

@@ -385,6 +385,18 @@ class TestRakeApplication < Rake::TestCase
385
385
  ARGV.clear
386
386
  end
387
387
 
388
+ def test_bad_run_with_backtrace
389
+ @app.intern(Rake::Task, "default").enhance { fail }
390
+ ARGV.clear
391
+ ARGV << '-f' << '-s' << '--backtrace'
392
+ assert_raises(SystemExit) {
393
+ _, err = capture_io { @app.run }
394
+ refute_match(/see full trace/, err)
395
+ }
396
+ ensure
397
+ ARGV.clear
398
+ end
399
+
388
400
  def test_run_with_bad_options
389
401
  @app.intern(Rake::Task, "default").enhance { fail }
390
402
  ARGV.clear
@@ -29,6 +29,7 @@ class TestRakeApplicationOptions < Rake::TestCase
29
29
 
30
30
  def test_default_options
31
31
  opts = command_line
32
+ assert_nil opts.backtrace
32
33
  assert_nil opts.classic_namespace
33
34
  assert_nil opts.dryrun
34
35
  assert_nil opts.ignore_system
@@ -40,6 +41,7 @@ class TestRakeApplicationOptions < Rake::TestCase
40
41
  assert_nil opts.show_tasks
41
42
  assert_nil opts.silent
42
43
  assert_nil opts.trace
44
+ assert_nil opts.thread_pool_size
43
45
  assert_equal ['rakelib'], opts.rakelib
44
46
  assert ! Rake::FileUtilsExt.verbose_flag
45
47
  assert ! Rake::FileUtilsExt.nowrite_flag
@@ -110,6 +112,18 @@ class TestRakeApplicationOptions < Rake::TestCase
110
112
  assert_equal :exit, @exit
111
113
  end
112
114
 
115
+ def test_jobs
116
+ flags(['--jobs', '4'], ['-j', '4']) do |opts|
117
+ assert_equal 4, opts.thread_pool_size
118
+ end
119
+ flags(['--jobs', 'asdas'], ['-j', 'asdas']) do |opts|
120
+ assert_equal 2, opts.thread_pool_size
121
+ end
122
+ flags('--jobs', '-j') do |opts|
123
+ assert_equal 2, opts.thread_pool_size
124
+ end
125
+ end
126
+
113
127
  def test_libdir
114
128
  flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
115
129
  $:.include?('xx')
@@ -197,12 +211,21 @@ class TestRakeApplicationOptions < Rake::TestCase
197
211
 
198
212
  def test_trace
199
213
  flags('--trace', '-t') do |opts|
200
- assert opts.trace
214
+ assert opts.trace, "should enable trace option"
215
+ assert opts.backtrace, "should enabled backtrace option"
201
216
  assert Rake::FileUtilsExt.verbose_flag
202
217
  assert ! Rake::FileUtilsExt.nowrite_flag
203
218
  end
204
219
  end
205
220
 
221
+ def test_backtrace
222
+ flags('--backtrace') do |opts|
223
+ assert opts.backtrace, "should enable backtrace option"
224
+ assert ! opts.trace, "should not enable trace option"
225
+ assert ! Rake::FileUtilsExt.verbose_flag
226
+ end
227
+ end
228
+
206
229
  def test_trace_rules
207
230
  flags('--rules') do |opts|
208
231
  assert opts.trace_rules
@@ -213,10 +236,17 @@ class TestRakeApplicationOptions < Rake::TestCase
213
236
  flags('--tasks', '-T') do |opts|
214
237
  assert_equal :tasks, opts.show_tasks
215
238
  assert_equal(//.to_s, opts.show_task_pattern.to_s)
239
+ assert_equal nil, opts.show_all_tasks
216
240
  end
217
241
  flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
218
242
  assert_equal :tasks, opts.show_tasks
219
243
  assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
244
+ assert_equal nil, opts.show_all_tasks
245
+ end
246
+ flags(['--tasks', 'xyz', '--comments']) do |opts|
247
+ assert_equal :tasks, opts.show_tasks
248
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
249
+ assert_equal false, opts.show_all_tasks
220
250
  end
221
251
  end
222
252
 
@@ -224,10 +254,17 @@ class TestRakeApplicationOptions < Rake::TestCase
224
254
  flags('--where', '-W') do |opts|
225
255
  assert_equal :lines, opts.show_tasks
226
256
  assert_equal(//.to_s, opts.show_task_pattern.to_s)
257
+ assert_equal true, opts.show_all_tasks
227
258
  end
228
259
  flags(['--where', 'xyz'], ['-Wxyz']) do |opts|
229
260
  assert_equal :lines, opts.show_tasks
230
261
  assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
262
+ assert_equal true, opts.show_all_tasks
263
+ end
264
+ flags(['--where', 'xyz', '--comments'], ['-Wxyz', '--comments']) do |opts|
265
+ assert_equal :lines, opts.show_tasks
266
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
267
+ assert_equal false, opts.show_all_tasks
231
268
  end
232
269
  end
233
270
 
@@ -268,7 +305,7 @@ class TestRakeApplicationOptions < Rake::TestCase
268
305
  assert_equal opts.trace, $trace
269
306
  assert_equal opts.dryrun, $dryrun
270
307
  assert_equal opts.silent, $silent
271
- end
308
+ end
272
309
  end
273
310
 
274
311
  assert_match(/deprecated/, err)
@@ -332,4 +369,3 @@ class TestRakeApplicationOptions < Rake::TestCase
332
369
  @app.options
333
370
  end
334
371
  end
335
-
@@ -36,11 +36,6 @@ class TestRakeDirectoryTask < Rake::TestCase
36
36
  assert_nil Task['c:/'].comment
37
37
  assert_equal "WIN32 DESC", Task['c:/a/b/c'].comment
38
38
  assert_nil Task['c:/a/b'].comment
39
- verbose(false) {
40
- Task['c:/a/b'].invoke
41
- }
42
- assert File.exist?('c:/a/b')
43
- refute File.exist?('c:/a/b/c')
44
39
  end
45
40
  end
46
41
  end
@@ -1,6 +1,10 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
  require 'fileutils'
3
3
 
4
+ def load_phony
5
+ load File.dirname(__FILE__) + "/../lib/rake/phony.rb"
6
+ end
7
+
4
8
  class TestRakeFileTask < Rake::TestCase
5
9
  include Rake
6
10
 
@@ -41,6 +45,23 @@ class TestRakeFileTask < Rake::TestCase
41
45
  assert ! t1.needed?, "Should not need to rebuild new file because of old"
42
46
  end
43
47
 
48
+ def test_file_times_new_depend_on_regular_task_timestamps
49
+ load_phony
50
+
51
+ name = "dummy"
52
+ task name
53
+
54
+ create_timed_files(NEWFILE)
55
+
56
+ t1 = Rake.application.intern(FileTask, NEWFILE).enhance([name])
57
+
58
+ assert t1.needed?, "depending on non-file task uses Time.now"
59
+
60
+ task(name => :phony)
61
+
62
+ assert ! t1.needed?, "unless the non-file task has a timestamp"
63
+ end
64
+
44
65
  def test_file_times_old_depends_on_new
45
66
  create_timed_files(OLDFILE, NEWFILE)
46
67
 
@@ -99,4 +120,3 @@ class TestRakeFileTask < Rake::TestCase
99
120
  end
100
121
 
101
122
  end
102
-
@@ -417,6 +417,28 @@ class TestRakeFunctional < Rake::TestCase
417
417
  assert_equal "1\n", @out
418
418
  end
419
419
 
420
+ def can_detect_signals?
421
+ system "ruby -e 'Process.kill \"TERM\", $$'"
422
+ status = $?
423
+ if @verbose
424
+ puts " SIG status = #{$?.inspect}"
425
+ puts " SIG status.respond_to?(:signaled?) = #{$?.respond_to?(:signaled?).inspect}"
426
+ puts " SIG status.signaled? = #{status.signaled?}" if status.respond_to?(:signaled?)
427
+ end
428
+ status.respond_to?(:signaled?) && status.signaled?
429
+ end
430
+
431
+ def test_signal_propagation_in_tests
432
+ if can_detect_signals?
433
+ rakefile_test_signal
434
+ rake
435
+ assert_match(/ATEST/, @out)
436
+ refute_match(/BTEST/, @out)
437
+ else
438
+ puts "\nWARNING: Signal detect seems broken on this system (#{__FILE__}:#{__LINE__})"
439
+ end
440
+ end
441
+
420
442
  private
421
443
 
422
444
  # Run a shell Ruby command with command line options (using the
@@ -47,5 +47,13 @@ class TestRakeMultiTask < Rake::TestCase
47
47
  assert @runs.index("B0") < @runs.index("B1")
48
48
  assert @runs.index("B1") < @runs.index("B2")
49
49
  end
50
+
51
+ def test_multitasks_with_parameters
52
+ task :a, [:arg] do |t,args| add_run(args[:arg]) end
53
+ multitask :b, [:arg] => [:a] do |t,args| add_run(args[:arg]+'mt') end
54
+ Task[:b].invoke "b"
55
+ assert @runs[0] == "b"
56
+ assert @runs[1] == "bmt"
57
+ end
50
58
  end
51
59
 
@@ -104,10 +104,12 @@ class TestRakeTask < Rake::TestCase
104
104
  end
105
105
 
106
106
  def test_clear
107
+ desc "a task"
107
108
  t = task("t" => "a") { }
108
109
  t.clear
109
110
  assert t.prerequisites.empty?, "prerequisites should be empty"
110
111
  assert t.actions.empty?, "actions should be empty"
112
+ assert_nil t.comment, "comments should be empty"
111
113
  end
112
114
 
113
115
  def test_clear_prerequisites
@@ -123,6 +125,22 @@ class TestRakeTask < Rake::TestCase
123
125
  assert t.actions.empty?, "actions should be empty"
124
126
  end
125
127
 
128
+ def test_clear_comments
129
+ desc "the original foo"
130
+ task :foo => [:x] do
131
+ # Dummy action
132
+ end
133
+
134
+ task(:foo).clear_comments
135
+
136
+ desc "a slightly different foo"
137
+ task :foo
138
+
139
+ assert_equal "a slightly different foo", task(:foo).comment
140
+ assert_equal ["x"], task(:foo).prerequisites
141
+ assert_equal 1, task(:foo).actions.size
142
+ end
143
+
126
144
  def test_find
127
145
  task :tfind
128
146
  assert_equal "tfind", Task[:tfind].name
@@ -264,4 +282,3 @@ class TestRakeTask < Rake::TestCase
264
282
  assert_equal "HI", t.comment
265
283
  end
266
284
  end
267
-
@@ -0,0 +1,146 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+ require 'rake/thread_pool'
3
+ require 'test/unit/assertions'
4
+
5
+ class TestRakeTestThreadPool < Rake::TestCase
6
+ include Rake
7
+
8
+ def test_pool_executes_in_current_thread_for_zero_threads
9
+ pool = ThreadPool.new(0)
10
+ f = pool.future{Thread.current}
11
+ pool.join
12
+ assert_equal Thread.current, f.call
13
+ end
14
+
15
+ def test_pool_executes_in_other_thread_for_pool_of_size_one
16
+ pool = ThreadPool.new(1)
17
+ f = pool.future{Thread.current}
18
+ pool.join
19
+ refute_equal Thread.current, f.call
20
+ end
21
+
22
+ def test_pool_executes_in_two_other_threads_for_pool_of_size_two
23
+ pool = ThreadPool.new(2)
24
+ threads = 2.times.collect{ pool.future{ sleep 0.1; Thread.current } }.each{|f|f.call}
25
+
26
+ refute_equal threads[0], threads[1]
27
+ refute_equal Thread.current, threads[0]
28
+ refute_equal Thread.current, threads[1]
29
+ end
30
+
31
+ def test_pool_creates_the_correct_number_of_threads
32
+ pool = ThreadPool.new(2)
33
+ threads = Set.new
34
+ t_mutex = Mutex.new
35
+ 10.times.each do
36
+ pool.future do
37
+ sleep 0.02
38
+ t_mutex.synchronize{ threads << Thread.current }
39
+ end
40
+ end
41
+ pool.join
42
+ assert_equal 2, threads.count
43
+ end
44
+
45
+ def test_pool_future_captures_arguments
46
+ pool = ThreadPool.new(2)
47
+ a = 'a'
48
+ b = 'b'
49
+ c = 5 # 5 throws an execption with 5.dup. It should be ignored
50
+ pool.future(a,c){ |a_var,ignore| a_var.capitalize!; b.capitalize! }
51
+ pool.join
52
+ assert_equal 'a', a
53
+ assert_equal 'b'.capitalize, b
54
+ end
55
+
56
+ def test_pool_join_empties_queue
57
+ pool = ThreadPool.new(2)
58
+ repeat = 25
59
+ repeat.times {
60
+ pool.future do
61
+ repeat.times {
62
+ pool.future do
63
+ repeat.times {
64
+ pool.future do end
65
+ }
66
+ end
67
+ }
68
+ end
69
+ }
70
+
71
+ pool.join
72
+ assert_equal true, pool.__send__(:__queue__).empty?
73
+ end
74
+
75
+ # test that throwing an exception way down in the blocks propagates
76
+ # to the top
77
+ def test_exceptions
78
+ pool = ThreadPool.new(10)
79
+
80
+ deep_exception_block = lambda do |count|
81
+ next raise Exception.new if ( count < 1 )
82
+ pool.future(count-1, &deep_exception_block).call
83
+ end
84
+
85
+ assert_raises(Exception) do
86
+ pool.future(2, &deep_exception_block).call
87
+ end
88
+
89
+ end
90
+
91
+ def test_pool_always_has_max_threads_doing_work
92
+ # here we need to test that even if some threads are halted, there
93
+ # are always at least max_threads that are not sleeping.
94
+ pool = ThreadPool.new(2)
95
+ initial_sleep_time = 0.2
96
+ future1 = pool.future { sleep initial_sleep_time }
97
+ dependent_futures = 5.times.collect { pool.future{ future1.call } }
98
+ future2 = pool.future { sleep initial_sleep_time }
99
+ future3 = pool.future { sleep 0.01 }
100
+
101
+ sleep initial_sleep_time / 2.0 # wait for everything to queue up
102
+
103
+ # at this point, we should have 5 threads sleeping depending on future1, and
104
+ # two threads doing work on future1 and future 2.
105
+ assert_equal pool.__send__(:__threads__).count, 7
106
+
107
+ # future 3 is in the queue because there aren't enough active threads to work on it.
108
+ assert_equal pool.__send__(:__queue__).size, 1
109
+
110
+ [future1, dependent_futures, future2, future3].flatten.each { |f| f.call }
111
+ pool.join
112
+ end
113
+
114
+ def test_pool_prevents_deadlock
115
+ pool = ThreadPool.new(5)
116
+
117
+ common_dependency_a = pool.future { sleep 0.2 }
118
+ futures_a = 10.times.collect { pool.future{ common_dependency_a.call; sleep(rand() * 0.01) } }
119
+
120
+ common_dependency_b = pool.future { futures_a.each { |f| f.call } }
121
+ futures_b = 10.times.collect { pool.future{ common_dependency_b.call; sleep(rand() * 0.01) } }
122
+
123
+ futures_b.each{|f|f.call}
124
+ pool.join
125
+ end
126
+
127
+ def test_pool_reports_correct_results
128
+ pool = ThreadPool.new(7)
129
+
130
+ a = 18
131
+ b = 5
132
+ c = 3
133
+
134
+ result = a.times.collect do
135
+ pool.future do
136
+ b.times.collect do
137
+ pool.future { sleep rand * 0.001; c }
138
+ end.inject(0) { |m,f| m+f.call }
139
+ end
140
+ end.inject(0) { |m,f| m+f.call }
141
+
142
+ assert_equal( (a*b*c), result )
143
+ pool.join
144
+ end
145
+
146
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3.beta.1
4
+ version: 0.9.3.beta.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-06 00:00:00.000000000 Z
12
+ date: 2012-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70183536931420 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '2.1'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70183536931420
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.1'
25
30
  description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies
26
31
  arespecified in standard Ruby syntax.
27
32
  email: jim@weirichhouse.org
@@ -58,6 +63,7 @@ extra_rdoc_files:
58
63
  - doc/release_notes/rake-0.9.0.rdoc
59
64
  - doc/release_notes/rake-0.9.1.rdoc
60
65
  - doc/release_notes/rake-0.9.2.rdoc
66
+ - doc/release_notes/rake-0.9.3.rdoc
61
67
  files:
62
68
  - .gemtest
63
69
  - install.rb
@@ -67,6 +73,7 @@ files:
67
73
  - Rakefile
68
74
  - TODO
69
75
  - bin/rake
76
+ - lib/rake.rb
70
77
  - lib/rake/alt_system.rb
71
78
  - lib/rake/application.rb
72
79
  - lib/rake/backtrace.rb
@@ -99,6 +106,7 @@ files:
99
106
  - lib/rake/name_space.rb
100
107
  - lib/rake/packagetask.rb
101
108
  - lib/rake/pathmap.rb
109
+ - lib/rake/phony.rb
102
110
  - lib/rake/pseudo_status.rb
103
111
  - lib/rake/rake_module.rb
104
112
  - lib/rake/rake_test_loader.rb
@@ -112,9 +120,9 @@ files:
112
120
  - lib/rake/task_manager.rb
113
121
  - lib/rake/tasklib.rb
114
122
  - lib/rake/testtask.rb
123
+ - lib/rake/thread_pool.rb
115
124
  - lib/rake/version.rb
116
125
  - lib/rake/win32.rb
117
- - lib/rake.rb
118
126
  - test/file_creation.rb
119
127
  - test/helper.rb
120
128
  - test/test_rake.rb
@@ -156,15 +164,16 @@ files:
156
164
  - test/test_rake_task_manager_argument_resolution.rb
157
165
  - test/test_rake_task_with_arguments.rb
158
166
  - test/test_rake_test_task.rb
167
+ - test/test_rake_thread_pool.rb
159
168
  - test/test_rake_top_level_functions.rb
160
169
  - test/test_rake_win32.rb
161
170
  - test/test_sys.rb
162
171
  - doc/command_line_usage.rdoc
172
+ - doc/example/Rakefile1
173
+ - doc/example/Rakefile2
163
174
  - doc/example/a.c
164
175
  - doc/example/b.c
165
176
  - doc/example/main.c
166
- - doc/example/Rakefile1
167
- - doc/example/Rakefile2
168
177
  - doc/glossary.rdoc
169
178
  - doc/jamis.rb
170
179
  - doc/proto_rake.rdoc
@@ -191,6 +200,7 @@ files:
191
200
  - doc/release_notes/rake-0.9.0.rdoc
192
201
  - doc/release_notes/rake-0.9.1.rdoc
193
202
  - doc/release_notes/rake-0.9.2.rdoc
203
+ - doc/release_notes/rake-0.9.3.rdoc
194
204
  homepage: http://rake.rubyforge.org
195
205
  licenses: []
196
206
  post_install_message:
@@ -217,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
227
  version: 1.3.2
218
228
  requirements: []
219
229
  rubyforge_project: rake
220
- rubygems_version: 1.8.7
230
+ rubygems_version: 1.8.24
221
231
  signing_key:
222
232
  specification_version: 3
223
233
  summary: Ruby based make-like utility.