rake 0.8.7 → 0.9.2

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 (140) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGES +78 -9
  3. data/{README → README.rdoc} +14 -10
  4. data/RRR +9 -0
  5. data/Rakefile +100 -125
  6. data/TODO +1 -1
  7. data/bin/rake +4 -3
  8. data/doc/command_line_usage.rdoc +18 -6
  9. data/doc/glossary.rdoc +2 -2
  10. data/doc/jamis.rb +2 -2
  11. data/doc/proto_rake.rdoc +22 -22
  12. data/doc/rake.1.gz +0 -0
  13. data/doc/rakefile.rdoc +56 -33
  14. data/doc/rational.rdoc +6 -6
  15. data/doc/release_notes/rake-0.4.15.rdoc +1 -1
  16. data/doc/release_notes/rake-0.5.0.rdoc +1 -1
  17. data/doc/release_notes/rake-0.7.0.rdoc +1 -1
  18. data/doc/release_notes/rake-0.7.2.rdoc +3 -3
  19. data/doc/release_notes/rake-0.7.3.rdoc +2 -2
  20. data/doc/release_notes/rake-0.8.0.rdoc +1 -1
  21. data/doc/release_notes/rake-0.8.2.rdoc +3 -3
  22. data/doc/release_notes/rake-0.8.3.rdoc +2 -2
  23. data/doc/release_notes/rake-0.8.4.rdoc +1 -1
  24. data/doc/release_notes/rake-0.8.5.rdoc +1 -1
  25. data/doc/release_notes/rake-0.8.6.rdoc +1 -1
  26. data/doc/release_notes/rake-0.8.7.rdoc +1 -1
  27. data/doc/release_notes/rake-0.9.0.rdoc +112 -0
  28. data/doc/release_notes/rake-0.9.1.rdoc +52 -0
  29. data/doc/release_notes/rake-0.9.2.rdoc +49 -0
  30. data/install.rb +14 -12
  31. data/lib/rake/alt_system.rb +7 -6
  32. data/lib/rake/application.rb +589 -0
  33. data/lib/rake/classic_namespace.rb +1 -0
  34. data/lib/rake/clean.rb +2 -4
  35. data/lib/rake/cloneable.rb +25 -0
  36. data/lib/rake/contrib/compositepublisher.rb +2 -5
  37. data/lib/rake/contrib/ftptools.rb +5 -8
  38. data/lib/rake/contrib/publisher.rb +2 -8
  39. data/lib/rake/contrib/rubyforgepublisher.rb +2 -4
  40. data/lib/rake/contrib/sshpublisher.rb +4 -6
  41. data/lib/rake/contrib/sys.rb +7 -25
  42. data/lib/rake/default_loader.rb +10 -0
  43. data/lib/rake/dsl_definition.rb +167 -0
  44. data/lib/rake/early_time.rb +18 -0
  45. data/lib/rake/ext/core.rb +27 -0
  46. data/lib/rake/ext/module.rb +39 -0
  47. data/lib/rake/ext/string.rb +167 -0
  48. data/lib/rake/ext/time.rb +14 -0
  49. data/lib/rake/file_creation_task.rb +24 -0
  50. data/lib/rake/file_list.rb +403 -0
  51. data/lib/rake/file_task.rb +47 -0
  52. data/lib/rake/file_utils.rb +112 -0
  53. data/lib/rake/file_utils_ext.rb +142 -0
  54. data/lib/rake/gempackagetask.rb +6 -90
  55. data/lib/rake/invocation_chain.rb +51 -0
  56. data/lib/rake/invocation_exception_mixin.rb +16 -0
  57. data/lib/rake/loaders/makefile.rb +13 -15
  58. data/lib/rake/multi_task.rb +16 -0
  59. data/lib/rake/name_space.rb +25 -0
  60. data/lib/rake/packagetask.rb +13 -12
  61. data/lib/rake/pathmap.rb +1 -0
  62. data/lib/rake/pseudo_status.rb +24 -0
  63. data/lib/rake/rake_module.rb +29 -0
  64. data/lib/rake/rake_test_loader.rb +10 -2
  65. data/lib/rake/rdoctask.rb +211 -190
  66. data/lib/rake/ruby182_test_unit_fix.rb +9 -7
  67. data/lib/rake/rule_recursion_overflow_error.rb +20 -0
  68. data/lib/rake/runtest.rb +4 -6
  69. data/lib/rake/task.rb +327 -0
  70. data/lib/rake/task_argument_error.rb +7 -0
  71. data/lib/rake/task_arguments.rb +74 -0
  72. data/lib/rake/task_manager.rb +307 -0
  73. data/lib/rake/tasklib.rb +1 -2
  74. data/lib/rake/testtask.rb +57 -27
  75. data/lib/rake/version.rb +10 -0
  76. data/lib/rake/win32.rb +4 -4
  77. data/lib/rake.rb +29 -2470
  78. data/test/data/access/Rakefile +35 -0
  79. data/test/data/comments/Rakefile +18 -0
  80. data/test/data/default/Rakefile +1 -3
  81. data/test/data/deprecated_import/Rakefile +1 -0
  82. data/test/data/dryrun/Rakefile +1 -1
  83. data/test/data/extra/Rakefile +1 -0
  84. data/test/data/file_creation_task/Rakefile +1 -3
  85. data/test/data/multidesc/Rakefile +0 -2
  86. data/test/data/namespace/Rakefile +9 -2
  87. data/test/data/rakelib/test1.rb +1 -0
  88. data/test/data/statusreturn/Rakefile +0 -2
  89. data/test/data/verbose/Rakefile +34 -0
  90. data/test/{filecreation.rb → file_creation.rb} +11 -9
  91. data/test/helper.rb +44 -0
  92. data/test/in_environment.rb +11 -6
  93. data/test/test_rake.rb +3 -6
  94. data/test/test_rake_application.rb +364 -0
  95. data/test/test_rake_application_options.rb +382 -0
  96. data/test/{test_clean.rb → test_rake_clean.rb} +2 -4
  97. data/test/{test_definitions.rb → test_rake_definitions.rb} +7 -12
  98. data/test/test_rake_directory_task.rb +55 -0
  99. data/test/test_rake_dsl.rb +73 -0
  100. data/test/{test_earlytime.rb → test_rake_early_time.rb} +3 -7
  101. data/test/{test_extension.rb → test_rake_extension.rb} +4 -8
  102. data/test/{test_file_creation_task.rb → test_rake_file_creation_task.rb} +7 -7
  103. data/test/{test_filelist.rb → test_rake_file_list.rb} +45 -35
  104. data/test/test_rake_file_list_path_map.rb +8 -0
  105. data/test/{test_file_task.rb → test_rake_file_task.rb} +23 -62
  106. data/test/{test_fileutils.rb → test_rake_file_utils.rb} +34 -33
  107. data/test/{test_ftp.rb → test_rake_ftp_file.rb} +5 -5
  108. data/test/{session_functional.rb → test_rake_functional.rb} +173 -44
  109. data/test/test_rake_invocation_chain.rb +52 -0
  110. data/test/{test_makefile_loader.rb → test_rake_makefile_loader.rb} +2 -5
  111. data/test/{test_multitask.rb → test_rake_multi_task.rb} +18 -12
  112. data/test/{test_namespace.rb → test_rake_name_space.rb} +4 -16
  113. data/test/test_rake_package_task.rb +78 -0
  114. data/test/{test_pathmap.rb → test_rake_path_map.rb} +5 -58
  115. data/test/test_rake_path_map_explode.rb +31 -0
  116. data/test/test_rake_path_map_partial.rb +18 -0
  117. data/test/{test_pseudo_status.rb → test_rake_pseudo_status.rb} +2 -8
  118. data/test/{test_rdoc_task.rb → test_rake_rdoc_task.rb} +22 -29
  119. data/test/{test_require.rb → test_rake_require.rb} +11 -11
  120. data/test/{test_rules.rb → test_rake_rules.rb} +12 -15
  121. data/test/{test_tasks.rb → test_rake_task.rb} +75 -178
  122. data/test/test_rake_task_argument_parsing.rb +116 -0
  123. data/test/{test_task_arguments.rb → test_rake_task_arguments.rb} +7 -10
  124. data/test/{test_tasklib.rb → test_rake_task_lib.rb} +2 -5
  125. data/test/{test_task_manager.rb → test_rake_task_manager.rb} +12 -40
  126. data/test/test_rake_task_manager_argument_resolution.rb +36 -0
  127. data/test/test_rake_task_with_arguments.rb +162 -0
  128. data/test/test_rake_test_task.rb +122 -0
  129. data/test/{test_top_level_functions.rb → test_rake_top_level_functions.rb} +12 -22
  130. data/test/{test_win32.rb → test_rake_win32.rb} +21 -10
  131. data/test/test_sys.rb +20 -0
  132. metadata +129 -51
  133. data/test/capture_stdout.rb +0 -26
  134. data/test/contrib/test_sys.rb +0 -47
  135. data/test/functional.rb +0 -15
  136. data/test/rake_test_setup.rb +0 -24
  137. data/test/test_application.rb +0 -675
  138. data/test/test_invocation_chain.rb +0 -81
  139. data/test/test_package_task.rb +0 -118
  140. data/test/test_test_task.rb +0 -77
@@ -1,14 +1,25 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  begin
4
- require 'rubygems'
5
- rescue LoadError => ex
2
+ old_verbose = $VERBOSE
3
+ $VERBOSE = nil
4
+ require 'session'
5
+ rescue LoadError
6
+ if File::ALT_SEPARATOR
7
+ puts "Unable to run functional tests on MS Windows. Skipping."
8
+ else
9
+ puts "Unable to run functional tests -- please run \"gem install session\""
10
+ end
11
+ ensure
12
+ $VERBOSE = old_verbose
6
13
  end
7
- require 'test/unit'
14
+
15
+ if defined?(Session)
16
+ if File::ALT_SEPARATOR
17
+ puts "Unable to run functional tests on MS Windows. Skipping."
18
+ end
19
+ end
20
+
21
+ require File.expand_path('../helper', __FILE__)
8
22
  require 'fileutils'
9
- require 'session'
10
- require 'test/in_environment'
11
- require 'test/rake_test_setup'
12
23
 
13
24
  # Version 2.1.9 of session has a bug where the @debug instance
14
25
  # variable is not initialized, causing warning messages. This snippet
@@ -21,19 +32,20 @@ module Session
21
32
  old_initialize(*args)
22
33
  end
23
34
  end
24
- end
35
+ end if defined? Session
25
36
 
26
- class FunctionalTest < Test::Unit::TestCase
27
- include InEnvironment
28
- include TestMethods
37
+ class TestRakeFunctional < Rake::TestCase
29
38
 
30
39
  RUBY_COMMAND = 'ruby'
31
40
 
32
41
  def setup
42
+ super
43
+
33
44
  @rake_path = File.expand_path("bin/rake")
34
45
  lib_path = File.expand_path("lib")
35
- @ruby_options = "-I#{lib_path} -I."
46
+ @ruby_options = ["-I#{lib_path}", "-I."]
36
47
  @verbose = ! ENV['VERBOSE'].nil?
48
+
37
49
  if @verbose
38
50
  puts
39
51
  puts
@@ -55,13 +67,13 @@ class FunctionalTest < Test::Unit::TestCase
55
67
  assert_status(1)
56
68
  end
57
69
 
58
- def test_env_availabe_at_top_scope
70
+ def test_env_available_at_top_scope
59
71
  Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end
60
72
  assert_match(/^TOPSCOPE$/, @out)
61
73
  assert_status
62
74
  end
63
75
 
64
- def test_env_availabe_at_task_scope
76
+ def test_env_available_at_task_scope
65
77
  Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end
66
78
  assert_match(/^TASKSCOPE$/, @out)
67
79
  assert_status
@@ -76,10 +88,10 @@ class FunctionalTest < Test::Unit::TestCase
76
88
  end
77
89
  assert_match %r{^rake a *# A / A2 *$}, @out
78
90
  assert_match %r{^rake b *# B *$}, @out
79
- assert_no_match %r{^rake c}, @out
91
+ refute_match %r{^rake c}, @out
80
92
  assert_match %r{^rake d *# x{65}\.\.\.$}, @out
81
93
  end
82
-
94
+
83
95
  def test_long_description
84
96
  in_environment("PWD" => "test/data/multidesc") do
85
97
  rake "--describe"
@@ -87,7 +99,14 @@ class FunctionalTest < Test::Unit::TestCase
87
99
  assert_match %r{^rake a\n *A / A2 *$}m, @out
88
100
  assert_match %r{^rake b\n *B *$}m, @out
89
101
  assert_match %r{^rake d\n *x{80}}m, @out
90
- assert_no_match %r{^rake c\n}m, @out
102
+ refute_match %r{^rake c\n}m, @out
103
+ end
104
+
105
+ def test_proper_namespace_access
106
+ in_environment("PWD" => "test/data/access") do
107
+ rake
108
+ end
109
+ assert_not_match %r{^BAD:}, @out
91
110
  end
92
111
 
93
112
  def test_rbext
@@ -108,12 +127,12 @@ class FunctionalTest < Test::Unit::TestCase
108
127
  in_environment('RAKE_SYSTEM' => 'test/data/sys') do
109
128
  rake '-g', "sys1", '-T', 'extra'
110
129
  end
111
- assert_no_match %r{extra:extra}, @out
130
+ refute_match %r{extra:extra}, @out
112
131
  end
113
132
 
114
- def test_by_default_rakelib_files_are_include
115
- in_environment('RAKE_SYSTEM' => 'test/data/sys') do
116
- rake '-T', 'extra'
133
+ def test_by_default_rakelib_files_are_included
134
+ in_environment('RAKE_SYSTEM' => 'test/data/sys', "PWD" => 'test/data/extra') do
135
+ rake '-T', 'extra', '--trace'
117
136
  end
118
137
  assert_match %r{extra:extra}, @out
119
138
  end
@@ -126,7 +145,7 @@ class FunctionalTest < Test::Unit::TestCase
126
145
  end
127
146
 
128
147
  def test_no_system
129
- in_environment('RAKE_SYSTEM' => 'test/data/sys') do
148
+ in_environment('RAKE_SYSTEM' => 'test/data/sys', "PWD" => "test/data/extra") do
130
149
  rake '-G', "sys1"
131
150
  end
132
151
  assert_match %r{^Don't know how to build task}, @err # emacs wart: '
@@ -156,12 +175,68 @@ class FunctionalTest < Test::Unit::TestCase
156
175
  assert_match %r{^No Rakefile found}, @err
157
176
  end
158
177
 
178
+ def test_invalid_command_line_options
179
+ in_environment("PWD" => "test/data/default") do
180
+ rake "--bad-options"
181
+ end
182
+ assert_match %r{invalid +option}i, @err
183
+ end
184
+
185
+ def test_inline_verbose_default_should_show_command
186
+ in_environment("PWD" => "test/data/verbose") do
187
+ rake "inline_verbose_default"
188
+ end
189
+ assert_match(/ruby -e/, @err)
190
+ end
191
+
192
+ def test_inline_verbose_true_should_show_command
193
+ in_environment("PWD" => "test/data/verbose") do
194
+ rake "inline_verbose_true"
195
+ end
196
+ assert_match(/ruby -e/, @err)
197
+ end
198
+
199
+ def test_inline_verbose_false_should_not_show_command
200
+ in_environment("PWD" => "test/data/verbose") do
201
+ rake "inline_verbose_false"
202
+ end
203
+ refute_match(/ruby -e/, @err)
204
+ end
205
+
206
+ def test_block_verbose_false_should_not_show_command
207
+ in_environment("PWD" => "test/data/verbose") do
208
+ rake "block_verbose_false"
209
+ end
210
+ refute_match(/ruby -e/, @err)
211
+ end
212
+
213
+ def test_block_verbose_true_should_show_command
214
+ in_environment("PWD" => "test/data/verbose") do
215
+ rake "block_verbose_true"
216
+ end
217
+ assert_match(/ruby -e/, @err)
218
+ end
219
+
220
+ def test_standalone_verbose_true_should_show_command
221
+ in_environment("PWD" => "test/data/verbose") do
222
+ rake "standalone_verbose_true"
223
+ end
224
+ assert_match(/ruby -e/, @err)
225
+ end
226
+
227
+ def test_standalone_verbose_false_should_not_show_command
228
+ in_environment("PWD" => "test/data/verbose") do
229
+ rake "standalone_verbose_false"
230
+ end
231
+ refute_match(/ruby -e/, @err)
232
+ end
233
+
159
234
  def test_dry_run
160
235
  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
163
- assert_no_match %r{DEFAULT}, @out
164
- assert_no_match %r{OTHER}, @out
236
+ assert_match %r{Execute \(dry run\) default}, @err
237
+ assert_match %r{Execute \(dry run\) other}, @err
238
+ refute_match %r{DEFAULT}, @out
239
+ refute_match %r{OTHER}, @out
165
240
  end
166
241
 
167
242
  # Test for the trace/dry_run bug found by Brian Chandler
@@ -173,7 +248,7 @@ class FunctionalTest < Test::Unit::TestCase
173
248
  in_environment("PWD" => "test/data/dryrun") do
174
249
  rake "--dry-run"
175
250
  end
176
- assert_no_match(/No such file/, @out)
251
+ refute_match(/No such file/, @out)
177
252
  assert_status
178
253
  end
179
254
 
@@ -186,7 +261,7 @@ class FunctionalTest < Test::Unit::TestCase
186
261
  in_environment("PWD" => "test/data/dryrun") do
187
262
  rake "--trace"
188
263
  end
189
- assert_no_match(/No such file/, @out)
264
+ refute_match(/No such file/, @out)
190
265
  assert_status
191
266
  end
192
267
 
@@ -284,7 +359,16 @@ class FunctionalTest < Test::Unit::TestCase
284
359
  assert_match(/^XYZ1\nXYZ2$/m, @out)
285
360
  end
286
361
  end
287
-
362
+
363
+ def test_file_task_dependencies_scoped_by_namespaces
364
+ in_environment("PWD" => "test/data/namespace") do
365
+ rake "scopedep.rb"
366
+ assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
367
+ end
368
+ ensure
369
+ remove_namespace_files
370
+ end
371
+
288
372
  def test_rake_returns_status_error_values
289
373
  in_environment("PWD" => "test/data/statusreturn") do
290
374
  rake "exit5"
@@ -299,30 +383,75 @@ class FunctionalTest < Test::Unit::TestCase
299
383
  end
300
384
  end
301
385
 
386
+ def test_comment_before_task_acts_like_desc
387
+ in_environment("PWD" => "test/data/comments") do
388
+ rake "-T"
389
+ end
390
+ refute_match(/comment for t1/, @out)
391
+ end
392
+
393
+ def test_comment_separated_from_task_by_blank_line_is_not_picked_up
394
+ Dir.chdir("test/data/comments") { rake("-T")}
395
+ assert_not_match("t2", @out)
396
+ end
397
+
398
+ def test_comment_after_desc_is_ignored
399
+ Dir.chdir("test/data/comments") { rake("-T")}
400
+ assert_match("override comment for t3", @out)
401
+ end
402
+
403
+ def test_comment_before_desc_is_ignored
404
+ Dir.chdir("test/data/comments") { rake("-T")}
405
+ assert_match("override comment for t4", @out)
406
+ end
407
+
408
+ def test_correct_number_of_tasks_reported
409
+ Dir.chdir("test/data/comments") { rake("-T")}
410
+ assert_equal(2, @out.split(/\n/).grep(/t\d/).size)
411
+ end
412
+
413
+ def test_file_list_is_requirable_separately
414
+ ruby "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'"
415
+ assert_equal "1\n", @out
416
+ assert_equal 0, @status
417
+ end
418
+
302
419
  private
303
420
 
421
+ def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect")
422
+ assert_nil Regexp.new(pattern).match(string), comment
423
+ end
424
+
304
425
  def remove_chaining_files
305
426
  %w(play.scpt play.app base).each do |fn|
306
427
  FileUtils.rm_f File.join("test/data/chains", fn)
307
428
  end
308
429
  end
309
430
 
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
431
+ def remove_namespace_files
432
+ %w(scopedep.rb).each do |fn|
433
+ FileUtils.rm_f File.join("test/data/namespace", fn)
319
434
  end
320
435
  end
321
-
322
- def rake(*option_list)
323
- options = option_list.join(' ')
436
+
437
+ # Run a shell Ruby command with command line options (using the
438
+ # default test options). Output is captured in @out, @err and
439
+ # @status.
440
+ def ruby(*option_list)
441
+ run_ruby(@ruby_options + option_list)
442
+ end
443
+
444
+ # Run a command line rake with the give rake options. Default
445
+ # command line ruby options are included. Output is captured in
446
+ # @out, @err and @status.
447
+ def rake(*rake_options)
448
+ run_ruby @ruby_options + [@rake_path] + rake_options
449
+ end
450
+
451
+ # Low level ruby command runner ...
452
+ def run_ruby(option_list)
324
453
  shell = Session::Shell.new
325
- command = self.class.format_command[@ruby_options, @rake_path, options]
454
+ command = "#{RUBY_COMMAND} " + option_list.join(' ')
326
455
  puts "COMMAND: [#{command}]" if @verbose
327
456
  @out, @err = shell.execute command
328
457
  @status = shell.exit_status
@@ -336,4 +465,4 @@ class FunctionalTest < Test::Unit::TestCase
336
465
  def assert_status(expected_status=0)
337
466
  assert_equal expected_status, @status
338
467
  end
339
- end
468
+ end if defined?(Session)
@@ -0,0 +1,52 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeInvocationChain < Rake::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @empty = Rake::InvocationChain::EMPTY
9
+
10
+ @first_member = "A"
11
+ @second_member = "B"
12
+ @one = @empty.append(@first_member)
13
+ @two = @one.append(@second_member)
14
+ end
15
+
16
+ def test_append
17
+ chain = @empty.append("A")
18
+
19
+ assert_equal 'TOP => A', chain.to_s # HACK
20
+ end
21
+
22
+ def test_append_one_circular
23
+ ex = assert_raises RuntimeError do
24
+ @one.append(@first_member)
25
+ end
26
+ assert_match(/circular +dependency/i, ex.message)
27
+ assert_match(/A.*=>.*A/, ex.message)
28
+ end
29
+
30
+ def test_append_two_circular
31
+ ex = assert_raises RuntimeError do
32
+ @two.append(@first_member)
33
+ end
34
+ assert_match(/A.*=>.*B.*=>.*A/, ex.message)
35
+ end
36
+
37
+ def test_member_eh_one
38
+ assert @one.member?(@first_member)
39
+ end
40
+
41
+ def test_member_eh_two
42
+ assert @two.member?(@first_member)
43
+ assert @two.member?(@second_member)
44
+ end
45
+
46
+ def test_to_s_empty
47
+ assert_equal "TOP", @empty.to_s
48
+ assert_equal "TOP => A", @one.to_s
49
+ end
50
+
51
+ end
52
+
@@ -1,10 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
1
+ require File.expand_path('../helper', __FILE__)
5
2
  require 'rake/loaders/makefile'
6
3
 
7
- class TestMakefileLoader < Test::Unit::TestCase
4
+ class TestRakeMakefileLoader < Rake::TestCase
8
5
  include Rake
9
6
 
10
7
  def test_parse
@@ -1,20 +1,27 @@
1
- #!/usr/bin/env ruby
1
+ require File.expand_path('../helper', __FILE__)
2
+ require 'thread'
2
3
 
3
- require 'test/unit'
4
- require 'rake'
5
-
6
- ######################################################################
7
- class TestMultiTask < Test::Unit::TestCase
4
+ class TestRakeMultiTask < Rake::TestCase
8
5
  include Rake
6
+ include Rake::DSL
9
7
 
10
8
  def setup
9
+ super
10
+
11
11
  Task.clear
12
12
  @runs = Array.new
13
+ @mutex = Mutex.new
14
+ end
15
+
16
+ def add_run(obj)
17
+ @mutex.synchronize do
18
+ @runs << obj
19
+ end
13
20
  end
14
21
 
15
22
  def test_running_multitasks
16
- task :a do 3.times do |i| @runs << "A#{i}"; sleep 0.01; end end
17
- task :b do 3.times do |i| @runs << "B#{i}"; sleep 0.01; end end
23
+ task :a do 3.times do |i| add_run("A#{i}"); sleep 0.01; end end
24
+ task :b do 3.times do |i| add_run("B#{i}"); sleep 0.01; end end
18
25
  multitask :both => [:a, :b]
19
26
  Task[:both].invoke
20
27
  assert_equal 6, @runs.size
@@ -25,9 +32,9 @@ class TestMultiTask < Test::Unit::TestCase
25
32
  end
26
33
 
27
34
  def test_all_multitasks_wait_on_slow_prerequisites
28
- task :slow do 3.times do |i| @runs << "S#{i}"; sleep 0.05 end end
29
- task :a => [:slow] do 3.times do |i| @runs << "A#{i}"; sleep 0.01 end end
30
- task :b => [:slow] do 3.times do |i| @runs << "B#{i}"; sleep 0.01 end end
35
+ task :slow do 3.times do |i| add_run("S#{i}"); sleep 0.05 end end
36
+ task :a => [:slow] do 3.times do |i| add_run("A#{i}"); sleep 0.01 end end
37
+ task :b => [:slow] do 3.times do |i| add_run("B#{i}"); sleep 0.01 end end
31
38
  multitask :both => [:a, :b]
32
39
  Task[:both].invoke
33
40
  assert_equal 9, @runs.size
@@ -42,4 +49,3 @@ class TestMultiTask < Test::Unit::TestCase
42
49
  end
43
50
  end
44
51
 
45
-
@@ -1,18 +1,6 @@
1
- #!/usr/bin/env ruby
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
- begin
4
- require 'rubygems'
5
- rescue LoadError
6
- # got no gems
7
- end
8
-
9
- require 'test/unit'
10
- require 'flexmock/test_unit'
11
- require 'rake'
12
- require 'test/rake_test_setup'
13
-
14
- class TestNameSpace < Test::Unit::TestCase
15
- include TestMethods
3
+ class TestRakeNameSpace < Rake::TestCase
16
4
 
17
5
  class TM
18
6
  include Rake::TaskManager
@@ -21,7 +9,7 @@ class TestNameSpace < Test::Unit::TestCase
21
9
  def test_namespace_creation
22
10
  mgr = TM.new
23
11
  ns = Rake::NameSpace.new(mgr, [])
24
- assert_not_nil ns
12
+ refute_nil ns
25
13
  end
26
14
 
27
15
  def test_namespace_lookup
@@ -30,7 +18,7 @@ class TestNameSpace < Test::Unit::TestCase
30
18
  mgr.define_task(Rake::Task, "t")
31
19
  end
32
20
 
33
- assert_not_nil ns["t"]
21
+ refute_nil ns["t"]
34
22
  assert_equal mgr["n:t"], ns["t"]
35
23
  end
36
24
 
@@ -0,0 +1,78 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+ require 'rake/packagetask'
3
+
4
+ class TestRakePackageTask < Rake::TestCase
5
+
6
+ def test_initialize
7
+ pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
8
+ p.package_files << "install.rb"
9
+ p.package_files.include(
10
+ '[A-Z]*',
11
+ 'bin/**/*',
12
+ 'lib/**/*.rb',
13
+ 'test/**/*.rb',
14
+ 'doc/**/*',
15
+ 'build/rubyapp.rb',
16
+ '*.blurb')
17
+ p.package_files.exclude(/\bCVS\b/)
18
+ p.package_files.exclude(/~$/)
19
+ p.package_dir = 'pkg'
20
+ p.need_tar = true
21
+ p.need_tar_gz = true
22
+ p.need_tar_bz2 = true
23
+ p.need_zip = true
24
+ }
25
+
26
+ assert_equal "pkg", pkg.package_dir
27
+ assert pkg.package_files.include?("bin/rake")
28
+ assert_equal 'pkgr', pkg.name
29
+ assert_equal '1.2.3', pkg.version
30
+ assert Rake::Task[:package]
31
+ assert Rake::Task['pkg/pkgr-1.2.3.tgz']
32
+ assert Rake::Task['pkg/pkgr-1.2.3.tar.gz']
33
+ assert Rake::Task['pkg/pkgr-1.2.3.tar.bz2']
34
+ assert Rake::Task['pkg/pkgr-1.2.3.zip']
35
+ assert Rake::Task['pkg/pkgr-1.2.3']
36
+ assert Rake::Task[:clobber_package]
37
+ assert Rake::Task[:repackage]
38
+ end
39
+
40
+ def test_initialize_no_version
41
+ e = assert_raises RuntimeError do
42
+ Rake::PackageTask.new 'pkgr'
43
+ end
44
+
45
+ assert_equal 'Version required (or :noversion)', e.message
46
+ end
47
+
48
+ def test_initialize_noversion
49
+ pkg = Rake::PackageTask.new 'pkgr', :noversion
50
+
51
+ assert_equal 'pkg', pkg.package_dir
52
+ assert_equal 'pkgr', pkg.name
53
+ assert_equal nil, pkg.version
54
+ end
55
+
56
+ def test_clone
57
+ pkg = Rake::PackageTask.new("x", :noversion)
58
+ p2 = pkg.clone
59
+ pkg.package_files << "y"
60
+ p2.package_files << "x"
61
+ assert_equal ["y"], pkg.package_files
62
+ assert_equal ["x"], p2.package_files
63
+ end
64
+
65
+ def test_package_name
66
+ pkg = Rake::PackageTask.new 'a', '1'
67
+
68
+ assert_equal 'a-1', pkg.package_name
69
+ end
70
+
71
+ def test_package_name_noversion
72
+ pkg = Rake::PackageTask.new 'a', :noversion
73
+
74
+ assert_equal 'a', pkg.package_name
75
+ end
76
+
77
+ end
78
+
@@ -1,11 +1,6 @@
1
- #!/usr/bin/env ruby
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
- require 'test/unit'
4
- require 'rake'
5
-
6
- # ====================================================================
7
- class TestPathMap < Test::Unit::TestCase
8
- include TestMethods
3
+ class TestRakePathMap < Rake::TestCase
9
4
 
10
5
  def test_returns_self_with_no_args
11
6
  assert_equal "abc.rb", "abc.rb".pathmap
@@ -26,7 +21,7 @@ class TestPathMap < Test::Unit::TestCase
26
21
 
27
22
  def test_n_returns_basename_without_extension
28
23
  assert_equal "abc", "abc.rb".pathmap("%n")
29
- assert_equal "abc", "abc".pathmap("%n")
24
+ assert_equal "abc", "abc".pathmap("%n")
30
25
  assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n")
31
26
  assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n")
32
27
  assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n")
@@ -87,7 +82,7 @@ class TestPathMap < Test::Unit::TestCase
87
82
  end
88
83
 
89
84
  def test_undefined_percent_causes_error
90
- ex = assert_exception(ArgumentError) {
85
+ assert_raises(ArgumentError) {
91
86
  "dir/abc.rb".pathmap("%z")
92
87
  }
93
88
  end
@@ -131,7 +126,7 @@ class TestPathMap < Test::Unit::TestCase
131
126
  end
132
127
 
133
128
  def test_pattern_with_invalid_operator
134
- ex = assert_exception(ArgumentError) do
129
+ ex = assert_raises(ArgumentError) do
135
130
  "abc.xyz".pathmap("%{src,bin}z")
136
131
  end
137
132
  assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
@@ -160,51 +155,3 @@ class TestPathMap < Test::Unit::TestCase
160
155
  end
161
156
  end
162
157
 
163
- class TestPathMapExplode < Test::Unit::TestCase
164
- def setup
165
- String.class_eval { public :pathmap_explode }
166
- end
167
-
168
- def teardown
169
- String.class_eval { protected :pathmap_explode }
170
- end
171
-
172
- def test_explode
173
- assert_equal ['a'], 'a'.pathmap_explode
174
- assert_equal ['a', 'b'], 'a/b'.pathmap_explode
175
- assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
176
- assert_equal ['/', 'a'], '/a'.pathmap_explode
177
- assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
178
- assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
179
- if File::ALT_SEPARATOR
180
- assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
181
- assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
182
- assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
183
- assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
184
- assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
185
- assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
186
- end
187
- end
188
- end
189
-
190
- class TestPathMapPartial < Test::Unit::TestCase
191
- def test_pathmap_partial
192
- @path = "1/2/file"
193
- def @path.call(n)
194
- pathmap_partial(n)
195
- end
196
- assert_equal("1", @path.call(1))
197
- assert_equal("1/2", @path.call(2))
198
- assert_equal("1/2", @path.call(3))
199
- assert_equal(".", @path.call(0))
200
- assert_equal("2", @path.call(-1))
201
- assert_equal("1/2", @path.call(-2))
202
- assert_equal("1/2", @path.call(-3))
203
- end
204
- end
205
-
206
- class TestFileListPathMap < Test::Unit::TestCase
207
- def test_file_list_supports_pathmap
208
- assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
209
- end
210
- end
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakePathMapExplode < Rake::TestCase
4
+ def setup
5
+ super
6
+
7
+ String.class_eval { public :pathmap_explode }
8
+ end
9
+
10
+ def teardown
11
+ String.class_eval { protected :pathmap_explode }
12
+ end
13
+
14
+ def test_explode
15
+ assert_equal ['a'], 'a'.pathmap_explode
16
+ assert_equal ['a', 'b'], 'a/b'.pathmap_explode
17
+ assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
18
+ assert_equal ['/', 'a'], '/a'.pathmap_explode
19
+ assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
20
+ assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
21
+ if File::ALT_SEPARATOR
22
+ assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
23
+ assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
24
+ assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
25
+ assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
26
+ assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
27
+ assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
28
+ end
29
+ end
30
+ end
31
+