rake 0.9.2 → 0.9.2.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.

Files changed (75) hide show
  1. data/CHANGES +13 -0
  2. data/README.rdoc +12 -15
  3. data/Rakefile +8 -44
  4. data/bin/rake +1 -0
  5. data/lib/rake.rb +4 -0
  6. data/lib/rake/application.rb +9 -3
  7. data/lib/rake/classic_namespace.rb +2 -0
  8. data/lib/rake/clean.rb +1 -0
  9. data/lib/rake/contrib/publisher.rb +10 -6
  10. data/lib/rake/contrib/sshpublisher.rb +5 -0
  11. data/lib/rake/dsl_definition.rb +13 -4
  12. data/lib/rake/ext/time.rb +3 -3
  13. data/lib/rake/file_utils.rb +9 -7
  14. data/lib/rake/file_utils_ext.rb +4 -1
  15. data/lib/rake/gempackagetask.rb +2 -0
  16. data/lib/rake/rake_test_loader.rb +15 -6
  17. data/lib/rake/rdoctask.rb +5 -1
  18. data/lib/rake/task_arguments.rb +4 -0
  19. data/lib/rake/version.rb +5 -7
  20. data/test/file_creation.rb +2 -2
  21. data/test/helper.rb +460 -12
  22. data/test/test_rake.rb +3 -1
  23. data/test/test_rake_application.rb +250 -125
  24. data/test/test_rake_application_options.rb +146 -193
  25. data/test/test_rake_clean.rb +2 -0
  26. data/test/test_rake_definitions.rb +6 -6
  27. data/test/test_rake_directory_task.rb +26 -35
  28. data/test/test_rake_dsl.rb +4 -0
  29. data/test/test_rake_file_creation_task.rb +1 -7
  30. data/test/test_rake_file_list.rb +128 -133
  31. data/test/test_rake_file_task.rb +1 -3
  32. data/test/test_rake_file_utils.rb +123 -70
  33. data/test/test_rake_functional.rb +234 -252
  34. data/test/test_rake_makefile_loader.rb +22 -1
  35. data/test/test_rake_package_task.rb +10 -9
  36. data/test/test_rake_path_map_explode.rb +3 -0
  37. data/test/test_rake_pseudo_status.rb +3 -2
  38. data/test/test_rake_rake_test_loader.rb +21 -0
  39. data/test/test_rake_rdoc_task.rb +5 -3
  40. data/test/test_rake_require.rb +8 -3
  41. data/test/test_rake_rules.rb +56 -75
  42. data/test/test_rake_task.rb +5 -9
  43. data/test/test_rake_task_argument_parsing.rb +33 -46
  44. data/test/test_rake_task_arguments.rb +2 -0
  45. data/test/test_rake_task_manager.rb +12 -0
  46. data/test/test_rake_task_with_arguments.rb +11 -0
  47. data/test/test_rake_test_task.rb +55 -57
  48. data/test/test_rake_top_level_functions.rb +52 -17
  49. data/test/test_rake_win32.rb +31 -42
  50. metadata +6 -52
  51. data/RRR +0 -9
  52. data/test/check_expansion.rb +0 -5
  53. data/test/check_no_expansion.rb +0 -5
  54. data/test/data/access/Rakefile +0 -35
  55. data/test/data/chains/Rakefile +0 -15
  56. data/test/data/comments/Rakefile +0 -18
  57. data/test/data/default/Rakefile +0 -17
  58. data/test/data/deprecated_import/Rakefile +0 -1
  59. data/test/data/dryrun/Rakefile +0 -22
  60. data/test/data/extra/Rakefile +0 -1
  61. data/test/data/file_creation_task/Rakefile +0 -31
  62. data/test/data/imports/Rakefile +0 -19
  63. data/test/data/imports/deps.mf +0 -1
  64. data/test/data/multidesc/Rakefile +0 -15
  65. data/test/data/namespace/Rakefile +0 -64
  66. data/test/data/rakelib/test1.rb +0 -4
  67. data/test/data/rbext/rakefile.rb +0 -3
  68. data/test/data/sample.mf +0 -14
  69. data/test/data/statusreturn/Rakefile +0 -6
  70. data/test/data/unittest/Rakefile +0 -1
  71. data/test/data/verbose/Rakefile +0 -34
  72. data/test/in_environment.rb +0 -35
  73. data/test/reqfile.rb +0 -3
  74. data/test/reqfile2.rb +0 -3
  75. data/test/shellcommand.rb +0 -3
@@ -12,7 +12,10 @@ module Rake
12
12
  class << self
13
13
  attr_accessor :verbose_flag, :nowrite_flag
14
14
  end
15
- FileUtilsExt.verbose_flag = nil
15
+
16
+ DEFAULT = Object.new
17
+
18
+ FileUtilsExt.verbose_flag = DEFAULT
16
19
  FileUtilsExt.nowrite_flag = false
17
20
 
18
21
  $fileutils_verbose = true
@@ -7,6 +7,8 @@ require 'rubygems/package_task'
7
7
 
8
8
  require 'rake'
9
9
 
10
+ # :stopdoc:
11
+
10
12
  module Rake
11
13
  GemPackageTask = Gem::PackageTask
12
14
  end
@@ -1,13 +1,22 @@
1
1
  require 'rake'
2
2
 
3
3
  # Load the test files from the command line.
4
+ argv = ARGV.select do |argument|
5
+ case argument
6
+ when /^-/ then
7
+ argument
8
+ when /\*/ then
9
+ FileList[argument].to_a.each do |file|
10
+ require File.expand_path file
11
+ end
4
12
 
5
- ARGV.each do |f|
6
- next if f =~ /^-/
7
-
8
- if f =~ /\*/
9
- FileList[f].to_a.each { |fn| require File.expand_path(fn) }
13
+ false
10
14
  else
11
- require File.expand_path(f)
15
+ require File.expand_path argument
16
+
17
+ false
12
18
  end
13
19
  end
20
+
21
+ ARGV.replace argv
22
+
@@ -1,6 +1,8 @@
1
1
  # rake/rdoctask is deprecated in favor of rdoc/task
2
2
 
3
- warn 'rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)'
3
+ if Rake.application
4
+ Rake.application.deprecate('require \'rake/rdoctask\'', 'require \'rdoc/task\' (in RDoc 2.4.2+)', __FILE__)
5
+ end
4
6
 
5
7
  require 'rubygems'
6
8
 
@@ -11,6 +13,8 @@ begin
11
13
  rescue LoadError, Gem::LoadError
12
14
  end
13
15
 
16
+ # :stopdoc:
17
+
14
18
  if defined?(RDoc::Task) then
15
19
  module Rake
16
20
  RDocTask = RDoc::Task unless const_defined? :RDocTask
@@ -43,6 +43,10 @@ module Rake
43
43
  @hash.each(&block)
44
44
  end
45
45
 
46
+ def values_at(*keys)
47
+ keys.map { |k| lookup(k) }
48
+ end
49
+
46
50
  def method_missing(sym, *args, &block)
47
51
  lookup(sym.to_sym)
48
52
  end
@@ -1,10 +1,8 @@
1
1
  module Rake
2
- module Version
3
- NUMBERS = [
4
- MAJOR = 0,
5
- MINOR = 9,
6
- BUILD = 2,
7
- ]
2
+ VERSION = '0.9.2.2'
3
+
4
+ module Version # :nodoc: all
5
+ MAJOR, MINOR, BUILD, PATCH = VERSION.split('.')
6
+ NUMBERS = [ MAJOR, MINOR, BUILD, PATCH ]
8
7
  end
9
- VERSION = Version::NUMBERS.join('.')
10
8
  end
@@ -1,6 +1,6 @@
1
1
  module FileCreation
2
- OLDFILE = "testdata/old"
3
- NEWFILE = "testdata/new"
2
+ OLDFILE = "old"
3
+ NEWFILE = "new"
4
4
 
5
5
  def create_timed_files(oldfile, *newfiles)
6
6
  return if (File.exist?(oldfile) &&
@@ -1,16 +1,22 @@
1
1
  require 'rubygems'
2
- require 'minitest/unit'
3
- require 'flexmock/test_unit_integration'
2
+
3
+ begin
4
+ gem 'minitest'
5
+ rescue Gem::LoadError
6
+ end
7
+
4
8
  require 'minitest/autorun'
5
9
  require 'rake'
10
+ require 'tmpdir'
6
11
  require File.expand_path('../file_creation', __FILE__)
7
- require File.expand_path('../in_environment', __FILE__)
8
12
 
9
- class Rake::TestCase < MiniTest::Unit::TestCase
10
- include FlexMock::ArgumentTypes
11
- include FlexMock::MockContainer
13
+ begin
14
+ require 'test/ruby/envutil'
15
+ rescue LoadError
16
+ # for ruby trunk
17
+ end
12
18
 
13
- include InEnvironment
19
+ class Rake::TestCase < MiniTest::Unit::TestCase
14
20
  include FileCreation
15
21
 
16
22
  include Rake::DSL
@@ -19,14 +25,53 @@ class Rake::TestCase < MiniTest::Unit::TestCase
19
25
  include Rake::TaskManager
20
26
  end
21
27
 
28
+ RUBY = defined?(EnvUtil) ? EnvUtil.rubybin : Gem.ruby
29
+
22
30
  def setup
31
+ ARGV.clear
32
+
23
33
  @orig_PWD = Dir.pwd
34
+ @orig_APPDATA = ENV['APPDATA']
35
+ @orig_HOME = ENV['HOME']
36
+ @orig_HOMEDRIVE = ENV['HOMEDRIVE']
37
+ @orig_HOMEPATH = ENV['HOMEPATH']
38
+ @orig_RAKE_COLUMNS = ENV['RAKE_COLUMNS']
39
+ @orig_RAKE_SYSTEM = ENV['RAKE_SYSTEM']
40
+ @orig_RAKEOPT = ENV['RAKEOPT']
41
+ @orig_USERPROFILE = ENV['USERPROFILE']
42
+ ENV.delete 'RAKE_COLUMNS'
43
+ ENV.delete 'RAKE_SYSTEM'
44
+ ENV.delete 'RAKEOPT'
45
+
46
+ tmpdir = Dir.chdir Dir.tmpdir do Dir.pwd end
47
+ @tempdir = File.join tmpdir, "test_rake_#{$$}"
48
+
49
+ FileUtils.mkdir_p @tempdir
50
+
51
+ Dir.chdir @tempdir
52
+
53
+ Rake.application = Rake::Application.new
54
+ Rake::TaskManager.record_task_metadata = true
55
+ RakeFileUtils.verbose_flag = false
24
56
  end
25
57
 
26
58
  def teardown
27
- flexmock_teardown
28
-
29
59
  Dir.chdir @orig_PWD
60
+ FileUtils.rm_rf @tempdir
61
+
62
+ if @orig_APPDATA then
63
+ ENV['APPDATA'] = @orig_APPDATA
64
+ else
65
+ ENV.delete 'APPDATA'
66
+ end
67
+
68
+ ENV['HOME'] = @orig_HOME
69
+ ENV['HOMEDRIVE'] = @orig_HOMEDRIVE
70
+ ENV['HOMEPATH'] = @orig_HOMEPATH
71
+ ENV['RAKE_COLUMNS'] = @orig_RAKE_COLUMNS
72
+ ENV['RAKE_SYSTEM'] = @orig_RAKE_SYSTEM
73
+ ENV['RAKEOPT'] = @orig_RAKEOPT
74
+ ENV['USERPROFILE'] = @orig_USERPROFILE
30
75
  end
31
76
 
32
77
  def ignore_deprecations
@@ -36,9 +81,412 @@ class Rake::TestCase < MiniTest::Unit::TestCase
36
81
  Rake.application.options.ignore_deprecate = false
37
82
  end
38
83
 
84
+ def rake_system_dir
85
+ @system_dir = 'system'
86
+
87
+ FileUtils.mkdir_p @system_dir
88
+
89
+ open File.join(@system_dir, 'sys1.rake'), 'w' do |io|
90
+ io << <<-SYS
91
+ task "sys1" do
92
+ puts "SYS1"
93
+ end
94
+ SYS
95
+ end
96
+
97
+ ENV['RAKE_SYSTEM'] = @system_dir
98
+ end
99
+
100
+ def rakefile contents
101
+ open 'Rakefile', 'w' do |io|
102
+ io << contents
103
+ end
104
+ end
105
+
106
+ def rakefile_access
107
+ rakefile <<-ACCESS
108
+ TOP_LEVEL_CONSTANT = 0
109
+
110
+ def a_top_level_function
111
+ end
112
+
113
+ task :default => [:work, :obj, :const]
114
+
115
+ task :work do
116
+ begin
117
+ a_top_level_function
118
+ puts "GOOD:M Top level methods can be called in tasks"
119
+ rescue NameError => ex
120
+ puts "BAD:M Top level methods can not be called in tasks"
121
+ end
122
+ end
123
+
124
+ # TODO: remove `disabled_' when DeprecatedObjectDSL removed
125
+ task :obj
126
+ task :disabled_obj do
127
+ begin
128
+ Object.new.instance_eval { task :xyzzy }
129
+ puts "BAD:D Rake DSL are polluting objects"
130
+ rescue StandardError => ex
131
+ puts "GOOD:D Rake DSL are not polluting objects"
132
+ end
133
+ end
134
+
135
+ task :const do
136
+ begin
137
+ TOP_LEVEL_CONSTANT
138
+ puts "GOOD:C Top level constants are available in tasks"
139
+ rescue StandardError => ex
140
+ puts "BAD:C Top level constants are NOT available in tasks"
141
+ end
142
+ end
143
+ ACCESS
144
+ end
145
+
146
+ def rakefile_chains
147
+ rakefile <<-DEFAULT
148
+ task :default => "play.app"
149
+
150
+ file "play.scpt" => "base" do |t|
151
+ cp t.prerequisites.first, t.name
152
+ end
153
+
154
+ rule ".app" => ".scpt" do |t|
155
+ cp t.source, t.name
156
+ end
157
+
158
+ file 'base' do
159
+ touch 'base'
160
+ end
161
+ DEFAULT
162
+ end
163
+
164
+ def rakefile_comments
165
+ rakefile <<-COMMENTS
166
+ # comment for t1
167
+ task :t1 do
168
+ end
169
+
170
+ # no comment or task because there's a blank line
171
+
172
+ task :t2 do
173
+ end
174
+
175
+ desc "override comment for t3"
176
+ # this is not the description
177
+ multitask :t3 do
178
+ end
179
+
180
+ # this is not the description
181
+ desc "override comment for t4"
182
+ file :t4 do
183
+ end
184
+ COMMENTS
185
+ end
186
+
187
+ def rakefile_default
188
+ rakefile <<-DEFAULT
189
+ if ENV['TESTTOPSCOPE']
190
+ puts "TOPSCOPE"
191
+ end
192
+
193
+ task :default do
194
+ puts "DEFAULT"
195
+ end
196
+
197
+ task :other => [:default] do
198
+ puts "OTHER"
199
+ end
200
+
201
+ task :task_scope do
202
+ if ENV['TESTTASKSCOPE']
203
+ puts "TASKSCOPE"
204
+ end
205
+ end
206
+ DEFAULT
207
+ end
208
+
209
+ def rakefile_dryrun
210
+ rakefile <<-DRYRUN
211
+ task :default => ["temp_main"]
212
+
213
+ file "temp_main" => [:all_apps] do touch "temp_main" end
214
+
215
+ task :all_apps => [:one, :two]
216
+ task :one => ["temp_one"]
217
+ task :two => ["temp_two"]
218
+
219
+ file "temp_one" do |t|
220
+ touch "temp_one"
221
+ end
222
+ file "temp_two" do |t|
223
+ touch "temp_two"
224
+ end
225
+
226
+ task :clean do
227
+ ["temp_one", "temp_two", "temp_main"].each do |file|
228
+ rm_f file
229
+ end
230
+ end
231
+ DRYRUN
232
+
233
+ FileUtils.touch 'temp_main'
234
+ FileUtils.touch 'temp_two'
235
+ end
236
+
237
+ def rakefile_extra
238
+ rakefile 'task :default'
239
+
240
+ FileUtils.mkdir_p 'rakelib'
241
+
242
+ open File.join('rakelib', 'extra.rake'), 'w' do |io|
243
+ io << <<-EXTRA_RAKE
244
+ # Added for testing
245
+
246
+ namespace :extra do
247
+ desc "An Extra Task"
248
+ task :extra do
249
+ puts "Read all about it"
250
+ end
251
+ end
252
+ EXTRA_RAKE
253
+ end
254
+ end
255
+
256
+ def rakefile_file_creation
257
+ rakefile <<-'FILE_CREATION'
258
+ N = 2
259
+
260
+ task :default => :run
261
+
262
+ BUILD_DIR = 'build'
263
+ task :clean do
264
+ rm_rf 'build'
265
+ rm_rf 'src'
266
+ end
267
+
268
+ task :run
269
+
270
+ TARGET_DIR = 'build/copies'
271
+
272
+ FileList['src/*'].each do |src|
273
+ directory TARGET_DIR
274
+ target = File.join TARGET_DIR, File.basename(src)
275
+ file target => [src, TARGET_DIR] do
276
+ cp src, target
277
+ # sleep 3 if src !~ /foo#{N-1}$/ # I'm commenting out this sleep, it doesn't seem to do anything.
278
+ end
279
+ task :run => target
280
+ end
281
+
282
+ task :prep => :clean do
283
+ mkdir_p 'src'
284
+ N.times do |n|
285
+ touch "src/foo#{n}"
286
+ end
287
+ end
288
+ FILE_CREATION
289
+ end
290
+
291
+ def rakefile_imports
292
+ rakefile <<-IMPORTS
293
+ require 'rake/loaders/makefile'
294
+
295
+ task :default
296
+
297
+ task :other do
298
+ puts "OTHER"
299
+ end
300
+
301
+ file "dynamic_deps" do |t|
302
+ open(t.name, "w") do |f| f.puts "puts 'DYNAMIC'" end
303
+ end
304
+
305
+ import "dynamic_deps"
306
+ import "static_deps"
307
+ import "static_deps"
308
+ import "deps.mf"
309
+ puts "FIRST"
310
+ IMPORTS
311
+
312
+ open 'deps.mf', 'w' do |io|
313
+ io << <<-DEPS
314
+ default: other
315
+ DEPS
316
+ end
317
+
318
+ open "static_deps", "w" do |f|
319
+ f.puts 'puts "STATIC"'
320
+ end
321
+ end
322
+
323
+ def rakefile_multidesc
324
+ rakefile <<-MULTIDESC
325
+ task :b
326
+
327
+ desc "A"
328
+ task :a
329
+
330
+ desc "B"
331
+ task :b
332
+
333
+ desc "A2"
334
+ task :a
335
+
336
+ task :c
337
+
338
+ desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
339
+ task :d
340
+ MULTIDESC
341
+ end
342
+
343
+ def rakefile_namespace
344
+ rakefile <<-NAMESPACE
345
+ desc "copy"
346
+ task :copy do
347
+ puts "COPY"
348
+ end
349
+
350
+ namespace "nest" do
351
+ desc "nest copy"
352
+ task :copy do
353
+ puts "NEST COPY"
354
+ end
355
+ task :xx => :copy
356
+ end
357
+
358
+ anon_ns = namespace do
359
+ desc "anonymous copy task"
360
+ task :copy do
361
+ puts "ANON COPY"
362
+ end
363
+ end
364
+
365
+ desc "Top level task to run the anonymous version of copy"
366
+ task :anon => anon_ns[:copy]
367
+
368
+ namespace "very" do
369
+ namespace "nested" do
370
+ task "run" => "rake:copy"
371
+ end
372
+ end
373
+
374
+ namespace "a" do
375
+ desc "Run task in the 'a' namespace"
376
+ task "run" do
377
+ puts "IN A"
378
+ end
379
+ end
380
+
381
+ namespace "b" do
382
+ desc "Run task in the 'b' namespace"
383
+ task "run" => "a:run" do
384
+ puts "IN B"
385
+ end
386
+ end
387
+
388
+ namespace "file1" do
389
+ file "xyz.rb" do
390
+ puts "XYZ1"
391
+ end
392
+ end
393
+
394
+ namespace "file2" do
395
+ file "xyz.rb" do
396
+ puts "XYZ2"
397
+ end
398
+ end
399
+
400
+ namespace "scopedep" do
401
+ task :prepare do
402
+ touch "scopedep.rb"
403
+ puts "PREPARE"
404
+ end
405
+ file "scopedep.rb" => [:prepare] do
406
+ puts "SCOPEDEP"
407
+ end
408
+ end
409
+ NAMESPACE
410
+ end
411
+
412
+ def rakefile_nosearch
413
+ FileUtils.touch 'dummy'
414
+ end
415
+
416
+ def rakefile_rakelib
417
+ FileUtils.mkdir_p 'rakelib'
418
+
419
+ Dir.chdir 'rakelib' do
420
+ open 'test1.rb', 'w' do |io|
421
+ io << <<-TEST1
422
+ task :default do
423
+ puts "TEST1"
39
424
  end
425
+ TEST1
426
+ end
427
+
428
+ open 'test2.rake', 'w' do |io|
429
+ io << <<-TEST1
430
+ task :default do
431
+ puts "TEST2"
432
+ end
433
+ TEST1
434
+ end
435
+ end
436
+ end
437
+
438
+ def rakefile_rbext
439
+ open 'rakefile.rb', 'w' do |io|
440
+ io << 'task :default do puts "OK" end'
441
+ end
442
+ end
443
+
444
+ def rakefile_unittest
445
+ rakefile '# Empty Rakefile for Unit Test'
40
446
 
41
- # workarounds for 1.8
42
- $" << 'test/helper.rb'
43
- Test::Unit.run = true if Test::Unit.respond_to? :run=
447
+ readme = File.join 'subdir', 'README'
448
+ FileUtils.mkdir_p File.dirname readme
449
+
450
+ FileUtils.touch readme
451
+ end
452
+
453
+ def rakefile_verbose
454
+ rakefile <<-VERBOSE
455
+ task :standalone_verbose_true do
456
+ verbose true
457
+ sh "#{RUBY} -e '0'"
458
+ end
459
+
460
+ task :standalone_verbose_false do
461
+ verbose false
462
+ sh "#{RUBY} -e '0'"
463
+ end
464
+
465
+ task :inline_verbose_default do
466
+ sh "#{RUBY} -e '0'"
467
+ end
468
+
469
+ task :inline_verbose_false do
470
+ sh "#{RUBY} -e '0'", :verbose => false
471
+ end
472
+
473
+ task :inline_verbose_true do
474
+ sh "#{RUBY} -e '0'", :verbose => true
475
+ end
476
+
477
+ task :block_verbose_true do
478
+ verbose(true) do
479
+ sh "#{RUBY} -e '0'"
480
+ end
481
+ end
482
+
483
+ task :block_verbose_false do
484
+ verbose(false) do
485
+ sh "#{RUBY} -e '0'"
486
+ end
487
+ end
488
+ VERBOSE
489
+ end
490
+
491
+ end
44
492