rake 0.8.7 → 0.9.0.beta.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 (122) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGES +77 -9
  3. data/{README → README.rdoc} +14 -10
  4. data/Rakefile +113 -110
  5. data/TODO +1 -1
  6. data/doc/command_line_usage.rdoc +18 -6
  7. data/doc/glossary.rdoc +2 -2
  8. data/doc/jamis.rb +2 -2
  9. data/doc/proto_rake.rdoc +22 -22
  10. data/doc/rake.1.gz +0 -0
  11. data/doc/rakefile.rdoc +60 -28
  12. data/doc/rational.rdoc +6 -6
  13. data/doc/release_notes/rake-0.4.15.rdoc +1 -1
  14. data/doc/release_notes/rake-0.5.0.rdoc +1 -1
  15. data/doc/release_notes/rake-0.7.0.rdoc +1 -1
  16. data/doc/release_notes/rake-0.7.2.rdoc +3 -3
  17. data/doc/release_notes/rake-0.7.3.rdoc +2 -2
  18. data/doc/release_notes/rake-0.8.0.rdoc +1 -1
  19. data/doc/release_notes/rake-0.8.2.rdoc +3 -3
  20. data/doc/release_notes/rake-0.8.3.rdoc +2 -2
  21. data/doc/release_notes/rake-0.8.4.rdoc +1 -1
  22. data/doc/release_notes/rake-0.8.5.rdoc +1 -1
  23. data/doc/release_notes/rake-0.8.6.rdoc +1 -1
  24. data/doc/release_notes/rake-0.8.7.rdoc +1 -1
  25. data/install.rb +14 -12
  26. data/lib/rake.rb +28 -2470
  27. data/lib/rake/alt_system.rb +7 -6
  28. data/lib/rake/application.rb +585 -0
  29. data/lib/rake/classic_namespace.rb +1 -0
  30. data/lib/rake/clean.rb +14 -14
  31. data/lib/rake/cloneable.rb +25 -0
  32. data/lib/rake/contrib/compositepublisher.rb +2 -5
  33. data/lib/rake/contrib/ftptools.rb +5 -8
  34. data/lib/rake/contrib/publisher.rb +2 -8
  35. data/lib/rake/contrib/rubyforgepublisher.rb +2 -4
  36. data/lib/rake/contrib/sshpublisher.rb +4 -6
  37. data/lib/rake/contrib/sys.rb +7 -25
  38. data/lib/rake/default_loader.rb +10 -0
  39. data/lib/rake/dsl.rb +2 -0
  40. data/lib/rake/dsl_definition.rb +146 -0
  41. data/lib/rake/early_time.rb +18 -0
  42. data/lib/rake/environment.rb +40 -0
  43. data/lib/rake/ext/core.rb +27 -0
  44. data/lib/rake/ext/module.rb +39 -0
  45. data/lib/rake/ext/string.rb +167 -0
  46. data/lib/rake/ext/time.rb +14 -0
  47. data/lib/rake/file_creation_task.rb +24 -0
  48. data/lib/rake/file_list.rb +403 -0
  49. data/lib/rake/file_task.rb +47 -0
  50. data/lib/rake/file_utils.rb +112 -0
  51. data/lib/rake/file_utils_ext.rb +132 -0
  52. data/lib/rake/gempackagetask.rb +6 -90
  53. data/lib/rake/invocation_chain.rb +51 -0
  54. data/lib/rake/invocation_exception_mixin.rb +16 -0
  55. data/lib/rake/loaders/makefile.rb +13 -15
  56. data/lib/rake/multi_task.rb +16 -0
  57. data/lib/rake/name_space.rb +25 -0
  58. data/lib/rake/packagetask.rb +13 -12
  59. data/lib/rake/pathmap.rb +1 -0
  60. data/lib/rake/pseudo_status.rb +24 -0
  61. data/lib/rake/rake_module.rb +25 -0
  62. data/lib/rake/rake_test_loader.rb +10 -2
  63. data/lib/rake/rdoctask.rb +211 -190
  64. data/lib/rake/ruby182_test_unit_fix.rb +9 -7
  65. data/lib/rake/rule_recursion_overflow_error.rb +20 -0
  66. data/lib/rake/runtest.rb +4 -6
  67. data/lib/rake/task.rb +327 -0
  68. data/lib/rake/task_argument_error.rb +7 -0
  69. data/lib/rake/task_arguments.rb +74 -0
  70. data/lib/rake/task_manager.rb +329 -0
  71. data/lib/rake/tasklib.rb +1 -2
  72. data/lib/rake/testtask.rb +51 -26
  73. data/lib/rake/version.rb +12 -0
  74. data/lib/rake/win32.rb +4 -4
  75. data/test/contrib/test_sys.rb +7 -30
  76. data/test/data/comments/Rakefile +18 -0
  77. data/test/data/default/Rakefile +1 -1
  78. data/test/data/dryrun/Rakefile +1 -1
  79. data/test/data/file_creation_task/Rakefile +1 -1
  80. data/test/data/namespace/Rakefile +9 -0
  81. data/test/data/rakelib/test1.rb +4 -2
  82. data/test/data/verbose/Rakefile +34 -0
  83. data/test/functional/functional_test.rb +25 -0
  84. data/test/{session_functional.rb → functional/session_based_tests.rb} +134 -23
  85. data/test/in_environment.rb +6 -4
  86. data/test/{test_application.rb → lib/application_test.rb} +277 -136
  87. data/test/{test_clean.rb → lib/clean_test.rb} +1 -0
  88. data/test/{test_definitions.rb → lib/definitions_test.rb} +2 -2
  89. data/test/lib/dsl_test.rb +52 -0
  90. data/test/{test_earlytime.rb → lib/earlytime_test.rb} +1 -2
  91. data/test/lib/environment_test.rb +18 -0
  92. data/test/{test_extension.rb → lib/extension_test.rb} +2 -2
  93. data/test/{test_file_creation_task.rb → lib/file_creation_task_test.rb} +0 -0
  94. data/test/{test_file_task.rb → lib/file_task_test.rb} +3 -3
  95. data/test/{test_filelist.rb → lib/filelist_test.rb} +28 -24
  96. data/test/{test_fileutils.rb → lib/fileutils_test.rb} +26 -21
  97. data/test/{test_ftp.rb → lib/ftp_test.rb} +0 -0
  98. data/test/{test_invocation_chain.rb → lib/invocation_chain_test.rb} +0 -0
  99. data/test/{test_makefile_loader.rb → lib/makefile_loader_test.rb} +0 -0
  100. data/test/{test_multitask.rb → lib/multitask_test.rb} +14 -6
  101. data/test/{test_namespace.rb → lib/namespace_test.rb} +0 -0
  102. data/test/lib/package_task_test.rb +82 -0
  103. data/test/{test_pathmap.rb → lib/pathmap_test.rb} +3 -2
  104. data/test/{test_pseudo_status.rb → lib/pseudo_status_test.rb} +0 -0
  105. data/test/{test_rake.rb → lib/rake_test.rb} +1 -1
  106. data/test/{test_rdoc_task.rb → lib/rdoc_task_test.rb} +19 -23
  107. data/test/{test_require.rb → lib/require_test.rb} +8 -2
  108. data/test/{test_rules.rb → lib/rules_test.rb} +1 -2
  109. data/test/{test_task_arguments.rb → lib/task_arguments_test.rb} +5 -5
  110. data/test/{test_task_manager.rb → lib/task_manager_test.rb} +5 -5
  111. data/test/{test_tasks.rb → lib/task_test.rb} +69 -4
  112. data/test/{test_tasklib.rb → lib/tasklib_test.rb} +0 -0
  113. data/test/{test_test_task.rb → lib/test_task_test.rb} +3 -3
  114. data/test/lib/testtask_test.rb +49 -0
  115. data/test/{test_top_level_functions.rb → lib/top_level_functions_test.rb} +3 -3
  116. data/test/{test_win32.rb → lib/win32_test.rb} +19 -0
  117. data/test/rake_test_setup.rb +4 -9
  118. data/test/ruby_version_test.rb +3 -0
  119. data/test/test_helper.rb +12 -0
  120. metadata +100 -44
  121. data/test/functional.rb +0 -15
  122. data/test/test_package_task.rb +0 -118
@@ -0,0 +1,12 @@
1
+ module Rake
2
+ module Version
3
+ NUMBERS = [
4
+ MAJOR = 0,
5
+ MINOR = 9,
6
+ BUILD = 0,
7
+ BETA = 'beta',
8
+ BETANUM = 0,
9
+ ]
10
+ end
11
+ VERSION = Version::NUMBERS.join('.')
12
+ end
@@ -5,12 +5,12 @@ module Rake
5
5
  # Win 32 interface methods for Rake. Windows specific functionality
6
6
  # will be placed here to collect that knowledge in one spot.
7
7
  module Win32
8
-
8
+
9
9
  # Error indicating a problem in locating the home directory on a
10
10
  # Win32 system.
11
11
  class Win32HomeError < RuntimeError
12
12
  end
13
-
13
+
14
14
  class << self
15
15
  # True if running on a windows system.
16
16
  def windows?
@@ -21,7 +21,7 @@ module Rake
21
21
  def rake_system(*cmd)
22
22
  AltSystem.system(*cmd)
23
23
  end
24
-
24
+
25
25
  # The standard directory containing system wide rake files on
26
26
  # Win 32 systems. Try the following environment variables (in
27
27
  # order):
@@ -49,7 +49,7 @@ module Rake
49
49
  def normalize(path)
50
50
  path.gsub(/\\/, '/')
51
51
  end
52
-
52
+
53
53
  end
54
54
  end
55
55
  end
@@ -2,40 +2,17 @@
2
2
 
3
3
  require 'test/unit'
4
4
  require 'test/filecreation'
5
- require 'rake/contrib/sys'
5
+ begin
6
+ old_verbose = $VERBOSE
7
+ $VERBOSE = nil
8
+ require 'rake/contrib/sys'
9
+ ensure
10
+ $VERBOSE = old_verbose
11
+ end
6
12
 
7
13
  class TestSys < Test::Unit::TestCase
8
14
  include FileCreation
9
15
 
10
- # def test_delete
11
- # create_file("testdata/a")
12
- # Sys.delete_all("testdata/a")
13
- # assert ! File.exist?("testdata/a")
14
- # end
15
-
16
- # def test_copy
17
- # create_file("testdata/a")
18
- # Sys.copy("testdata/a", "testdata/b")
19
- # assert File.exist?("testdata/b")
20
- # end
21
-
22
- # def test_for_files
23
- # test_files = ["testdata/a.pl", "testdata/c.pl", "testdata/b.rb"]
24
- # test_files.each { |fn| create_file(fn) }
25
- # list = []
26
- # Sys.for_files("testdata/*.pl", "testdata/*.rb") { |fn|
27
- # list << fn
28
- # }
29
- # assert_equal test_files.sort, list.sort
30
- # end
31
-
32
- # def test_indir
33
- # here = Dir.pwd
34
- # Sys.makedirs("testdata/dir")
35
- # assert_equal "#{here}/testdata/dir", Sys.indir("testdata/dir") { Dir.pwd }
36
- # assert_equal here, Dir.pwd
37
- # end
38
-
39
16
  def test_split_all
40
17
  assert_equal ['a'], Sys.split_all('a')
41
18
  assert_equal ['..'], Sys.split_all('..')
@@ -0,0 +1,18 @@
1
+ # comment for t1
2
+ task :t1 do
3
+ end
4
+
5
+ # no comment or task because there's a blank line
6
+
7
+ task :t2 do
8
+ end
9
+
10
+ desc "override comment for t3"
11
+ # this is not the description
12
+ multitask :t3 do
13
+ end
14
+
15
+ # this is not the description
16
+ desc "override comment for t4"
17
+ file :t4 do
18
+ end
@@ -16,4 +16,4 @@ task :task_scope do
16
16
  if ENV['TESTTASKSCOPE']
17
17
  puts "TASKSCOPE"
18
18
  end
19
- end
19
+ end
@@ -1,4 +1,4 @@
1
- #
1
+ #
2
2
 
3
3
  task :default => ["temp_main"]
4
4
 
@@ -5,7 +5,7 @@ N = 2
5
5
  task :default => :run
6
6
 
7
7
  BUILD_DIR = 'build'
8
- task :clean do
8
+ task :clean do
9
9
  rm_rf 'build'
10
10
  rm_rf 'src'
11
11
  end
@@ -55,3 +55,12 @@ namespace "file2" do
55
55
  end
56
56
  end
57
57
 
58
+ namespace "scopedep" do
59
+ task :prepare do
60
+ touch "scopedep.rb"
61
+ puts "PREPARE"
62
+ end
63
+ file "scopedep.rb" => [:prepare] do
64
+ puts "SCOPEDEP"
65
+ end
66
+ end
@@ -1,3 +1,5 @@
1
- task :default do
2
- puts "TEST1"
1
+ Rake::DSL.environment do
2
+ task :default do
3
+ puts "TEST1"
4
+ end
3
5
  end
@@ -0,0 +1,34 @@
1
+
2
+ task :standalone_verbose_true do
3
+ verbose true
4
+ sh "ruby -e '0'"
5
+ end
6
+
7
+ task :standalone_verbose_false do
8
+ verbose false
9
+ sh "ruby -e '0'"
10
+ end
11
+
12
+ task :inline_verbose_default do
13
+ sh "ruby -e '0'"
14
+ end
15
+
16
+ task :inline_verbose_false do
17
+ sh "ruby -e '0'", :verbose => false
18
+ end
19
+
20
+ task :inline_verbose_true do
21
+ sh "ruby -e '0'", :verbose => true
22
+ end
23
+
24
+ task :block_verbose_true do
25
+ verbose(true) do
26
+ sh "ruby -e '0'"
27
+ end
28
+ end
29
+
30
+ task :block_verbose_false do
31
+ verbose(false) do
32
+ sh "ruby -e '0'"
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ old_verbose = $VERBOSE
5
+ require 'rubygems'
6
+ $VERBOSE = nil
7
+ gem 'session'
8
+ require 'session'
9
+ rescue LoadError
10
+ if File::ALT_SEPARATOR
11
+ puts "Unable to run functional tests on MS Windows. Skipping."
12
+ else
13
+ puts "Unable to run functional tests -- please run \"gem install session\""
14
+ end
15
+ ensure
16
+ $VERBOSE = old_verbose
17
+ end
18
+
19
+ if defined?(Session)
20
+ if File::ALT_SEPARATOR
21
+ puts "Unable to run functional tests on MS Windows. Skipping."
22
+ else
23
+ require 'test/functional/session_based_tests.rb'
24
+ end
25
+ end
@@ -2,13 +2,14 @@
2
2
 
3
3
  begin
4
4
  require 'rubygems'
5
- rescue LoadError => ex
5
+ rescue LoadError
6
6
  end
7
7
  require 'test/unit'
8
8
  require 'fileutils'
9
9
  require 'session'
10
10
  require 'test/in_environment'
11
11
  require 'test/rake_test_setup'
12
+ require 'rake'
12
13
 
13
14
  # Version 2.1.9 of session has a bug where the @debug instance
14
15
  # variable is not initialized, causing warning messages. This snippet
@@ -23,7 +24,7 @@ module Session
23
24
  end
24
25
  end
25
26
 
26
- class FunctionalTest < Test::Unit::TestCase
27
+ class SessionBasedTests < Test::Unit::TestCase
27
28
  include InEnvironment
28
29
  include TestMethods
29
30
 
@@ -32,7 +33,7 @@ class FunctionalTest < Test::Unit::TestCase
32
33
  def setup
33
34
  @rake_path = File.expand_path("bin/rake")
34
35
  lib_path = File.expand_path("lib")
35
- @ruby_options = "-I#{lib_path} -I."
36
+ @ruby_options = ["-I#{lib_path}", "-I."]
36
37
  @verbose = ! ENV['VERBOSE'].nil?
37
38
  if @verbose
38
39
  puts
@@ -55,13 +56,13 @@ class FunctionalTest < Test::Unit::TestCase
55
56
  assert_status(1)
56
57
  end
57
58
 
58
- def test_env_availabe_at_top_scope
59
+ def test_env_available_at_top_scope
59
60
  Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end
60
61
  assert_match(/^TOPSCOPE$/, @out)
61
62
  assert_status
62
63
  end
63
64
 
64
- def test_env_availabe_at_task_scope
65
+ def test_env_available_at_task_scope
65
66
  Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end
66
67
  assert_match(/^TASKSCOPE$/, @out)
67
68
  assert_status
@@ -79,7 +80,7 @@ class FunctionalTest < Test::Unit::TestCase
79
80
  assert_no_match %r{^rake c}, @out
80
81
  assert_match %r{^rake d *# x{65}\.\.\.$}, @out
81
82
  end
82
-
83
+
83
84
  def test_long_description
84
85
  in_environment("PWD" => "test/data/multidesc") do
85
86
  rake "--describe"
@@ -111,7 +112,7 @@ class FunctionalTest < Test::Unit::TestCase
111
112
  assert_no_match %r{extra:extra}, @out
112
113
  end
113
114
 
114
- def test_by_default_rakelib_files_are_include
115
+ def test_by_default_rakelib_files_are_included
115
116
  in_environment('RAKE_SYSTEM' => 'test/data/sys') do
116
117
  rake '-T', 'extra'
117
118
  end
@@ -156,10 +157,66 @@ class FunctionalTest < Test::Unit::TestCase
156
157
  assert_match %r{^No Rakefile found}, @err
157
158
  end
158
159
 
160
+ def test_invalid_command_line_options
161
+ in_environment("PWD" => "test/data/default") do
162
+ rake "--bad-options"
163
+ end
164
+ assert_match %r{invalid +option}i, @err
165
+ end
166
+
167
+ def test_inline_verbose_default_should_show_command
168
+ in_environment("PWD" => "test/data/verbose") do
169
+ rake "inline_verbose_default"
170
+ end
171
+ assert_match(/ruby -e/, @err)
172
+ end
173
+
174
+ def test_inline_verbose_true_should_show_command
175
+ in_environment("PWD" => "test/data/verbose") do
176
+ rake "inline_verbose_true"
177
+ end
178
+ assert_match(/ruby -e/, @err)
179
+ end
180
+
181
+ def test_inline_verbose_false_should_not_show_command
182
+ in_environment("PWD" => "test/data/verbose") do
183
+ rake "inline_verbose_false"
184
+ end
185
+ assert_no_match(/ruby -e/, @err)
186
+ end
187
+
188
+ def test_block_verbose_false_should_not_show_command
189
+ in_environment("PWD" => "test/data/verbose") do
190
+ rake "block_verbose_false"
191
+ end
192
+ assert_no_match(/ruby -e/, @err)
193
+ end
194
+
195
+ def test_block_verbose_true_should_show_command
196
+ in_environment("PWD" => "test/data/verbose") do
197
+ rake "block_verbose_true"
198
+ end
199
+ assert_match(/ruby -e/, @err)
200
+ end
201
+
202
+ def test_standalone_verbose_true_should_show_command
203
+ in_environment("PWD" => "test/data/verbose") do
204
+ rake "standalone_verbose_true"
205
+ end
206
+ assert_match(/ruby -e/, @err)
207
+ end
208
+
209
+ def test_standalone_verbose_false_should_not_show_command
210
+ in_environment("PWD" => "test/data/verbose") do
211
+ rake "standalone_verbose_false"
212
+ end
213
+ assert_no_match(/ruby -e/, @err)
214
+ end
215
+
159
216
  def test_dry_run
160
217
  in_environment("PWD" => "test/data/default") do rake "-n", "other" end
161
- assert_match %r{Execute \(dry run\) default}, @out
162
- assert_match %r{Execute \(dry run\) other}, @out
218
+ assert_match %r{Execute \(dry run\) default}, @err
219
+ assert_match %r{Execute \(dry run\) other}, @err
163
220
  assert_no_match %r{DEFAULT}, @out
164
221
  assert_no_match %r{OTHER}, @out
165
222
  end
@@ -284,7 +341,16 @@ class FunctionalTest < Test::Unit::TestCase
284
341
  assert_match(/^XYZ1\nXYZ2$/m, @out)
285
342
  end
286
343
  end
287
-
344
+
345
+ def test_file_task_dependencies_scoped_by_namespaces
346
+ in_environment("PWD" => "test/data/namespace") do
347
+ rake "scopedep.rb"
348
+ assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
349
+ end
350
+ ensure
351
+ remove_namespace_files
352
+ end
353
+
288
354
  def test_rake_returns_status_error_values
289
355
  in_environment("PWD" => "test/data/statusreturn") do
290
356
  rake "exit5"
@@ -299,30 +365,75 @@ class FunctionalTest < Test::Unit::TestCase
299
365
  end
300
366
  end
301
367
 
368
+ def test_comment_before_task_acts_like_desc
369
+ in_environment("PWD" => "test/data/comments") do
370
+ rake "-T"
371
+ end
372
+ assert_match("comment for t1", @out)
373
+ end
374
+
375
+ def test_comment_separated_from_task_by_blank_line_is_not_picked_up
376
+ Dir.chdir("test/data/comments") { rake("-T")}
377
+ assert_not_match("t2", @out)
378
+ end
379
+
380
+ def test_comment_after_desc_is_ignored
381
+ Dir.chdir("test/data/comments") { rake("-T")}
382
+ assert_match("override comment for t3", @out)
383
+ end
384
+
385
+ def test_comment_before_desc_is_ignored
386
+ Dir.chdir("test/data/comments") { rake("-T")}
387
+ assert_match("override comment for t4", @out)
388
+ end
389
+
390
+ def test_correct_number_of_tasks_reported
391
+ Dir.chdir("test/data/comments") { rake("-T")}
392
+ assert_equal(3, @out.split(/\n/).grep(/t\d/).size)
393
+ end
394
+
395
+ def test_file_list_is_requirable_separately
396
+ ruby "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'"
397
+ assert_equal "1\n", @out
398
+ assert_equal 0, @status
399
+ end
400
+
302
401
  private
303
402
 
403
+ def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect")
404
+ assert_nil Regexp.new(pattern).match(string), comment
405
+ end
406
+
304
407
  def remove_chaining_files
305
408
  %w(play.scpt play.app base).each do |fn|
306
409
  FileUtils.rm_f File.join("test/data/chains", fn)
307
410
  end
308
411
  end
309
412
 
310
- class << self
311
- def format_command
312
- @format_command ||= lambda { |ruby_options, rake_path, options|
313
- "ruby #{ruby_options} #{rake_path} #{options}"
314
- }
315
- end
316
-
317
- def format_command=(fmt_command)
318
- @format_command = fmt_command
413
+ def remove_namespace_files
414
+ %w(scopedep.rb).each do |fn|
415
+ FileUtils.rm_f File.join("test/data/namespace", fn)
319
416
  end
320
417
  end
321
-
322
- def rake(*option_list)
323
- options = option_list.join(' ')
418
+
419
+ # Run a shell Ruby command with command line options (using the
420
+ # default test options). Output is captured in @out, @err and
421
+ # @status.
422
+ def ruby(*option_list)
423
+ run_ruby(@ruby_options + option_list)
424
+ end
425
+
426
+ # Run a command line rake with the give rake options. Default
427
+ # command line ruby options are included. Output is captured in
428
+ # @out, @err and @status.
429
+ def rake(*rake_options)
430
+ run_ruby @ruby_options + [@rake_path] + rake_options
431
+ end
432
+
433
+ # Low level ruby command runner ...
434
+ def run_ruby(option_list)
324
435
  shell = Session::Shell.new
325
- command = self.class.format_command[@ruby_options, @rake_path, options]
436
+ command = "#{RUBY_COMMAND} " + option_list.join(' ')
326
437
  puts "COMMAND: [#{command}]" if @verbose
327
438
  @out, @err = shell.execute command
328
439
  @status = shell.exit_status