rake 10.5.0 → 13.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +2032 -288
  3. data/README.rdoc +40 -24
  4. data/doc/jamis.rb +1 -0
  5. data/doc/rake.1 +139 -124
  6. data/doc/rakefile.rdoc +2 -4
  7. data/{bin → exe}/rake +1 -7
  8. data/lib/rake/application.rb +164 -93
  9. data/lib/rake/backtrace.rb +4 -2
  10. data/lib/rake/clean.rb +7 -5
  11. data/lib/rake/cloneable.rb +1 -0
  12. data/lib/rake/cpu_counter.rb +10 -28
  13. data/lib/rake/default_loader.rb +1 -0
  14. data/lib/rake/dsl_definition.rb +8 -13
  15. data/lib/rake/early_time.rb +1 -0
  16. data/lib/rake/ext/core.rb +1 -0
  17. data/lib/rake/ext/string.rb +22 -21
  18. data/lib/rake/file_creation_task.rb +4 -3
  19. data/lib/rake/file_list.rb +34 -27
  20. data/lib/rake/file_task.rb +19 -7
  21. data/lib/rake/file_utils.rb +37 -33
  22. data/lib/rake/file_utils_ext.rb +8 -18
  23. data/lib/rake/invocation_chain.rb +1 -0
  24. data/lib/rake/invocation_exception_mixin.rb +1 -0
  25. data/lib/rake/late_time.rb +2 -1
  26. data/lib/rake/linked_list.rb +24 -15
  27. data/lib/rake/loaders/makefile.rb +5 -4
  28. data/lib/rake/multi_task.rb +2 -1
  29. data/lib/rake/name_space.rb +1 -1
  30. data/lib/rake/packagetask.rb +40 -17
  31. data/lib/rake/phony.rb +2 -1
  32. data/lib/rake/private_reader.rb +1 -0
  33. data/lib/rake/promise.rb +13 -12
  34. data/lib/rake/pseudo_status.rb +1 -0
  35. data/lib/rake/rake_module.rb +30 -1
  36. data/lib/rake/rake_test_loader.rb +9 -4
  37. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  38. data/lib/rake/scope.rb +3 -2
  39. data/lib/rake/task.rb +82 -31
  40. data/lib/rake/task_argument_error.rb +1 -0
  41. data/lib/rake/task_arguments.rb +15 -4
  42. data/lib/rake/task_manager.rb +56 -32
  43. data/lib/rake/tasklib.rb +2 -14
  44. data/lib/rake/testtask.rb +37 -61
  45. data/lib/rake/thread_history_display.rb +4 -3
  46. data/lib/rake/thread_pool.rb +16 -17
  47. data/lib/rake/trace_output.rb +2 -1
  48. data/lib/rake/version.rb +4 -1
  49. data/lib/rake/win32.rb +10 -15
  50. data/lib/rake.rb +34 -43
  51. data/rake.gemspec +101 -0
  52. metadata +24 -223
  53. data/.autotest +0 -7
  54. data/.rubocop.yml +0 -27
  55. data/.togglerc +0 -7
  56. data/CONTRIBUTING.rdoc +0 -38
  57. data/Manifest.txt +0 -166
  58. data/Rakefile +0 -81
  59. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  60. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  61. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  62. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  63. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  64. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  65. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  66. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  67. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  68. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  69. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  70. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  71. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  72. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  73. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  74. data/doc/release_notes/rake-0.8.6.rdoc +0 -37
  75. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  76. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  77. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  78. data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
  79. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  80. data/doc/release_notes/rake-0.9.3.rdoc +0 -102
  81. data/doc/release_notes/rake-0.9.4.rdoc +0 -60
  82. data/doc/release_notes/rake-0.9.5.rdoc +0 -55
  83. data/doc/release_notes/rake-0.9.6.rdoc +0 -64
  84. data/doc/release_notes/rake-10.0.0.rdoc +0 -178
  85. data/doc/release_notes/rake-10.0.1.rdoc +0 -58
  86. data/doc/release_notes/rake-10.0.2.rdoc +0 -53
  87. data/doc/release_notes/rake-10.0.3.rdoc +0 -191
  88. data/doc/release_notes/rake-10.1.0.rdoc +0 -61
  89. data/lib/rake/alt_system.rb +0 -110
  90. data/lib/rake/contrib/.document +0 -1
  91. data/lib/rake/contrib/compositepublisher.rb +0 -21
  92. data/lib/rake/contrib/ftptools.rb +0 -137
  93. data/lib/rake/contrib/publisher.rb +0 -81
  94. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  95. data/lib/rake/contrib/sshpublisher.rb +0 -61
  96. data/lib/rake/contrib/sys.rb +0 -4
  97. data/lib/rake/ext/module.rb +0 -2
  98. data/lib/rake/ext/pathname.rb +0 -25
  99. data/lib/rake/ext/time.rb +0 -18
  100. data/lib/rake/gempackagetask.rb +0 -4
  101. data/lib/rake/pathmap.rb +0 -3
  102. data/lib/rake/rdoctask.rb +0 -4
  103. data/lib/rake/ruby182_test_unit_fix.rb +0 -29
  104. data/lib/rake/runtest.rb +0 -27
  105. data/rakelib/publish.rake +0 -20
  106. data/rakelib/test_times.rake +0 -25
  107. data/test/file_creation.rb +0 -34
  108. data/test/helper.rb +0 -129
  109. data/test/support/rakefile_definitions.rb +0 -478
  110. data/test/support/ruby_runner.rb +0 -34
  111. data/test/test_private_reader.rb +0 -42
  112. data/test/test_rake.rb +0 -40
  113. data/test/test_rake_application.rb +0 -643
  114. data/test/test_rake_application_options.rb +0 -468
  115. data/test/test_rake_backtrace.rb +0 -119
  116. data/test/test_rake_clean.rb +0 -61
  117. data/test/test_rake_cpu_counter.rb +0 -68
  118. data/test/test_rake_definitions.rb +0 -84
  119. data/test/test_rake_directory_task.rb +0 -76
  120. data/test/test_rake_dsl.rb +0 -40
  121. data/test/test_rake_early_time.rb +0 -31
  122. data/test/test_rake_extension.rb +0 -59
  123. data/test/test_rake_file_creation_task.rb +0 -56
  124. data/test/test_rake_file_list.rb +0 -670
  125. data/test/test_rake_file_list_path_map.rb +0 -8
  126. data/test/test_rake_file_task.rb +0 -197
  127. data/test/test_rake_file_utils.rb +0 -314
  128. data/test/test_rake_ftp_file.rb +0 -74
  129. data/test/test_rake_functional.rb +0 -482
  130. data/test/test_rake_invocation_chain.rb +0 -64
  131. data/test/test_rake_late_time.rb +0 -18
  132. data/test/test_rake_linked_list.rb +0 -84
  133. data/test/test_rake_makefile_loader.rb +0 -46
  134. data/test/test_rake_multi_task.rb +0 -64
  135. data/test/test_rake_name_space.rb +0 -57
  136. data/test/test_rake_package_task.rb +0 -79
  137. data/test/test_rake_path_map.rb +0 -168
  138. data/test/test_rake_path_map_explode.rb +0 -34
  139. data/test/test_rake_path_map_partial.rb +0 -18
  140. data/test/test_rake_pathname_extensions.rb +0 -15
  141. data/test/test_rake_pseudo_status.rb +0 -21
  142. data/test/test_rake_rake_test_loader.rb +0 -20
  143. data/test/test_rake_reduce_compat.rb +0 -26
  144. data/test/test_rake_require.rb +0 -40
  145. data/test/test_rake_rules.rb +0 -388
  146. data/test/test_rake_scope.rb +0 -44
  147. data/test/test_rake_task.rb +0 -393
  148. data/test/test_rake_task_argument_parsing.rb +0 -119
  149. data/test/test_rake_task_arguments.rb +0 -127
  150. data/test/test_rake_task_lib.rb +0 -9
  151. data/test/test_rake_task_manager.rb +0 -178
  152. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  153. data/test/test_rake_task_with_arguments.rb +0 -172
  154. data/test/test_rake_test_task.rb +0 -146
  155. data/test/test_rake_thread_pool.rb +0 -145
  156. data/test/test_rake_top_level_functions.rb +0 -71
  157. data/test/test_rake_win32.rb +0 -72
  158. data/test/test_thread_history_display.rb +0 -101
  159. data/test/test_trace_output.rb +0 -52
@@ -1,393 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'fileutils'
3
-
4
- class TestRakeTask < Rake::TestCase
5
- include Rake
6
-
7
- def setup
8
- super
9
-
10
- Task.clear
11
- Rake::TaskManager.record_task_metadata = true
12
- end
13
-
14
- def teardown
15
- Rake::TaskManager.record_task_metadata = false
16
- Rake.application.thread_pool.join
17
-
18
- super
19
- end
20
-
21
- def test_create
22
- arg = nil
23
- t = task(:name) { |task| arg = task; 1234 }
24
- assert_equal "name", t.name
25
- assert_equal [], t.prerequisites
26
- assert t.needed?
27
- t.execute(0)
28
- assert_equal t, arg
29
- assert_nil t.source
30
- assert_equal [], t.sources
31
- assert_equal 1, t.locations.size
32
- assert_match(/#{Regexp.quote(__FILE__)}/, t.locations.first)
33
- end
34
-
35
- def test_inspect
36
- t = task(:foo => [:bar, :baz])
37
- assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
38
- end
39
-
40
- def test_invoke
41
- runlist = []
42
- t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
43
- task(:t2) { |t| runlist << t.name }
44
- task(:t3) { |t| runlist << t.name }
45
- assert_equal ["t2", "t3"], t1.prerequisites
46
- t1.invoke
47
- assert_equal ["t2", "t3", "t1"], runlist
48
- end
49
-
50
- def test_invoke_with_circular_dependencies
51
- runlist = []
52
- t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 }
53
- t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
54
- assert_equal ["t2"], t1.prerequisites
55
- assert_equal ["t1"], t2.prerequisites
56
- ex = assert_raises RuntimeError do
57
- t1.invoke
58
- end
59
- assert_match(/circular dependency/i, ex.message)
60
- assert_match(/t1 => t2 => t1/, ex.message)
61
- end
62
-
63
- def test_dry_run_prevents_actions
64
- Rake.application.options.dryrun = true
65
- runlist = []
66
- t1 = task(:t1) { |t| runlist << t.name; 3321 }
67
- _, err = capture_io { t1.invoke }
68
- assert_match(/execute .*t1/i, err)
69
- assert_match(/dry run/i, err)
70
- refute_match(/invoke/i, err)
71
- assert_equal [], runlist
72
- ensure
73
- Rake.application.options.dryrun = false
74
- end
75
-
76
- def test_tasks_can_be_traced
77
- Rake.application.options.trace = true
78
- t1 = task(:t1)
79
- _, err = capture_io {
80
- t1.invoke
81
- }
82
- assert_match(/invoke t1/i, err)
83
- assert_match(/execute t1/i, err)
84
- ensure
85
- Rake.application.options.trace = false
86
- end
87
-
88
- def test_no_double_invoke
89
- runlist = []
90
- t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
91
- task(:t2 => [:t3]) { |t| runlist << t.name }
92
- task(:t3) { |t| runlist << t.name }
93
- t1.invoke
94
- assert_equal ["t3", "t2", "t1"], runlist
95
- end
96
-
97
- def test_can_double_invoke_with_reenable
98
- runlist = []
99
- t1 = task(:t1) { |t| runlist << t.name }
100
- t1.invoke
101
- t1.reenable
102
- t1.invoke
103
- assert_equal ["t1", "t1"], runlist
104
- end
105
-
106
- def test_clear
107
- desc "a task"
108
- t = task("t" => "a") { }
109
- t.clear
110
- assert t.prerequisites.empty?, "prerequisites should be empty"
111
- assert t.actions.empty?, "actions should be empty"
112
- assert_nil t.comment, "comments should be empty"
113
- end
114
-
115
- def test_clear_prerequisites
116
- t = task("t" => ["a", "b"])
117
- assert_equal ['a', 'b'], t.prerequisites
118
- t.clear_prerequisites
119
- assert_equal [], t.prerequisites
120
- end
121
-
122
- def test_clear_actions
123
- t = task("t") { }
124
- t.clear_actions
125
- assert t.actions.empty?, "actions should be empty"
126
- end
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
-
144
- def test_find
145
- task :tfind
146
- assert_equal "tfind", Task[:tfind].name
147
- ex = assert_raises(RuntimeError) { Task[:leaves] }
148
- assert_equal "Don't know how to build task 'leaves' (see --tasks)", ex.message
149
- end
150
-
151
- def test_defined
152
- assert ! Task.task_defined?(:a)
153
- task :a
154
- assert Task.task_defined?(:a)
155
- end
156
-
157
- def test_multi_invocations
158
- runs = []
159
- p = proc do |t| runs << t.name end
160
- task({ :t1 => [:t2, :t3] }, &p)
161
- task({ :t2 => [:t3] }, &p)
162
- task(:t3, &p)
163
- Task[:t1].invoke
164
- assert_equal ["t1", "t2", "t3"], runs.sort
165
- end
166
-
167
- def test_task_list
168
- task :t2
169
- task :t1 => [:t2]
170
- assert_equal ["t1", "t2"], Task.tasks.map { |t| t.name }
171
- end
172
-
173
- def test_task_gives_name_on_to_s
174
- task :abc
175
- assert_equal "abc", Task[:abc].to_s
176
- end
177
-
178
- def test_symbols_can_be_prerequisites
179
- task :a => :b
180
- assert_equal ["b"], Task[:a].prerequisites
181
- end
182
-
183
- def test_strings_can_be_prerequisites
184
- task :a => "b"
185
- assert_equal ["b"], Task[:a].prerequisites
186
- end
187
-
188
- def test_arrays_can_be_prerequisites
189
- task :a => ["b", "c"]
190
- assert_equal ["b", "c"], Task[:a].prerequisites
191
- end
192
-
193
- def test_filelists_can_be_prerequisites
194
- task :a => FileList.new.include("b", "c")
195
- assert_equal ["b", "c"], Task[:a].prerequisites
196
- end
197
-
198
- def test_prerequisite_tasks_returns_tasks_not_strings
199
- a = task :a => ["b", "c"]
200
- b = task :b
201
- c = task :c
202
- assert_equal [b, c], a.prerequisite_tasks
203
- end
204
-
205
- def test_prerequisite_tasks_fails_if_prerequisites_are_undefined
206
- a = task :a => ["b", "c"]
207
- task :b
208
- assert_raises(RuntimeError) do
209
- a.prerequisite_tasks
210
- end
211
- end
212
-
213
- def test_prerequisite_tasks_honors_namespaces
214
- a = b = nil
215
- namespace "X" do
216
- a = task :a => ["b", "c"]
217
- b = task :b
218
- end
219
- c = task :c
220
-
221
- assert_equal [b, c], a.prerequisite_tasks
222
- end
223
-
224
- def test_all_prerequisite_tasks_includes_all_prerequisites
225
- a = task :a => "b"
226
- b = task :b => ["c", "d"]
227
- c = task :c => "e"
228
- d = task :d
229
- e = task :e
230
-
231
- assert_equal [b, c, d, e], a.all_prerequisite_tasks.sort_by { |t| t.name }
232
- end
233
-
234
- def test_all_prerequisite_tasks_does_not_include_duplicates
235
- a = task :a => ["b", "c"]
236
- b = task :b => "c"
237
- c = task :c
238
-
239
- assert_equal [b, c], a.all_prerequisite_tasks.sort_by { |t| t.name }
240
- end
241
-
242
- def test_all_prerequisite_tasks_includes_self_on_cyclic_dependencies
243
- a = task :a => "b"
244
- b = task :b => "a"
245
-
246
- assert_equal [a, b], a.all_prerequisite_tasks.sort_by { |t| t.name }
247
- end
248
-
249
- def test_timestamp_returns_now_if_all_prereqs_have_no_times
250
- a = task :a => ["b", "c"]
251
- task :b
252
- task :c
253
-
254
- assert_in_delta Time.now, a.timestamp, 0.1, 'computer too slow?'
255
- end
256
-
257
- def test_timestamp_returns_latest_prereq_timestamp
258
- a = task :a => ["b", "c"]
259
- b = task :b
260
- c = task :c
261
-
262
- now = Time.now
263
- def b.timestamp() Time.now + 10 end
264
- def c.timestamp() Time.now + 5 end
265
-
266
- assert_in_delta now, a.timestamp, 0.1, 'computer too slow?'
267
- end
268
-
269
- def test_always_multitask
270
- mx = Mutex.new
271
- result = []
272
-
273
- t_a = task(:a) do |t|
274
- sleep 0.2
275
- mx.synchronize { result << t.name }
276
- end
277
-
278
- t_b = task(:b) do |t|
279
- mx.synchronize { result << t.name }
280
- end
281
-
282
- t_c = task(:c => [:a, :b]) do |t|
283
- mx.synchronize { result << t.name }
284
- end
285
-
286
- t_c.invoke
287
-
288
- # task should always run in order
289
- assert_equal ['a', 'b', 'c'], result
290
-
291
- [t_a, t_b, t_c].each { |t| t.reenable }
292
- result.clear
293
-
294
- Rake.application.options.always_multitask = true
295
- t_c.invoke
296
-
297
- # with multitask, task 'b' should grab the mutex first
298
- assert_equal ['b', 'a', 'c'], result
299
- end
300
-
301
- def test_investigation_output
302
- t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
303
- task(:t2)
304
- task(:t3)
305
- out = t1.investigation
306
- assert_match(/class:\s*Rake::Task/, out)
307
- assert_match(/needed:\s*true/, out)
308
- assert_match(/pre-requisites:\s*--t[23]/, out)
309
- end
310
-
311
- # NOTE: Rail-ties uses comment=.
312
- def test_comment_setting
313
- t = task(:t, :name, :rev)
314
- t.comment = "A Comment"
315
- assert_equal "A Comment", t.comment
316
- end
317
-
318
- def test_comments_with_sentences
319
- desc "Comment 1. Comment 2."
320
- t = task(:t, :name, :rev)
321
- assert_equal "Comment 1", t.comment
322
- end
323
-
324
- def test_comments_with_tabbed_sentences
325
- desc "Comment 1.\tComment 2."
326
- t = task(:t, :name, :rev)
327
- assert_equal "Comment 1", t.comment
328
- end
329
-
330
- def test_comments_with_decimal_points
331
- desc "Revision 1.2.3."
332
- t = task(:t, :name, :rev)
333
- assert_equal "Revision 1.2.3", t.comment
334
- end
335
-
336
- def test_comments_do_not_set
337
- t = task(:t, :name, :rev)
338
- assert_equal nil, t.comment
339
- end
340
-
341
- def test_comments_is_nil
342
- t = task(:t, :name, :rev)
343
- t.comment = nil
344
- assert_equal nil, t.comment
345
- end
346
-
347
- def test_extended_comments
348
- desc %{
349
- This is a comment.
350
-
351
- And this is the extended comment.
352
- name -- Name of task to execute.
353
- rev -- Software revision to use.
354
- }
355
- t = task(:t, :name, :rev)
356
- assert_equal "[name,rev]", t.arg_description
357
- assert_equal "This is a comment", t.comment
358
- assert_match(/^\s*name -- Name/, t.full_comment)
359
- assert_match(/^\s*rev -- Software/, t.full_comment)
360
- assert_match(/\A\s*This is a comment\.$/, t.full_comment)
361
- end
362
-
363
- def test_multiple_comments
364
- desc "line one"
365
- t = task(:t)
366
- desc "line two"
367
- task(:t)
368
- assert_equal "line one / line two", t.comment
369
- end
370
-
371
- def test_duplicate_comments
372
- desc "line one"
373
- t = task(:t)
374
- desc "line one"
375
- task(:t)
376
- assert_equal "line one", t.comment
377
- end
378
-
379
- def test_interspersed_duplicate_comments
380
- desc "line one"
381
- t = task(:t)
382
- desc "line two"
383
- task(:t)
384
- desc "line one"
385
- task(:t)
386
- assert_equal "line one / line two", t.comment
387
- end
388
-
389
- def test_source_is_first_prerequisite
390
- t = task :t => ["preqA", "preqB"]
391
- assert_equal "preqA", t.source
392
- end
393
- end
@@ -1,119 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeTaskArgumentParsing < Rake::TestCase
4
- def setup
5
- super
6
-
7
- @app = Rake::Application.new
8
- end
9
-
10
- def test_name_only
11
- name, args = @app.parse_task_string("name")
12
- assert_equal "name", name
13
- assert_equal [], args
14
- end
15
-
16
- def test_empty_args
17
- name, args = @app.parse_task_string("name[]")
18
- assert_equal "name", name
19
- assert_equal [], args
20
- end
21
-
22
- def test_one_argument
23
- name, args = @app.parse_task_string("name[one]")
24
- assert_equal "name", name
25
- assert_equal ["one"], args
26
- end
27
-
28
- def test_two_arguments
29
- name, args = @app.parse_task_string("name[one,two]")
30
- assert_equal "name", name
31
- assert_equal ["one", "two"], args
32
- end
33
-
34
- def test_can_handle_spaces_between_args
35
- name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
36
- assert_equal "name", name
37
- assert_equal ["one", "two", "three", "four"], args
38
- end
39
-
40
- def test_keeps_embedded_spaces
41
- name, args = @app.parse_task_string("name[a one ana, two]")
42
- assert_equal "name", name
43
- assert_equal ["a one ana", "two"], args
44
- end
45
-
46
- def test_can_handle_commas_in_args
47
- name, args = @app.parse_task_string("name[one, two, three_a\\, three_b, four]")
48
- assert_equal "name", name
49
- assert_equal ["one", "two", "three_a, three_b", "four"], args
50
- end
51
-
52
- def test_treat_blank_arg_as_empty_string
53
- name, args = @app.parse_task_string("name[one,]")
54
- assert_equal "name", name
55
- assert_equal ["one", ""], args
56
-
57
- name, args = @app.parse_task_string("name[one,,two]")
58
- assert_equal "name", name
59
- assert_equal ["one", "", "two"], args
60
- end
61
-
62
- def test_terminal_width_using_env
63
- app = Rake::Application.new
64
- app.terminal_columns = 1234
65
-
66
- assert_equal 1234, app.terminal_width
67
- end
68
-
69
- def test_terminal_width_using_stty
70
- def @app.unix?() true end
71
- def @app.dynamic_width_stty() 1235 end
72
- def @app.dynamic_width_tput() 0 end
73
-
74
- assert_equal 1235, @app.terminal_width
75
- end
76
-
77
- def test_terminal_width_using_tput
78
- def @app.unix?() true end
79
- def @app.dynamic_width_stty() 0 end
80
- def @app.dynamic_width_tput() 1236 end
81
-
82
- assert_equal 1236, @app.terminal_width
83
- end
84
-
85
- def test_terminal_width_using_hardcoded_80
86
- def @app.unix?() false end
87
-
88
- assert_equal 80, @app.terminal_width
89
- end
90
-
91
- def test_terminal_width_with_failure
92
- def @app.unix?() raise end
93
-
94
- assert_equal 80, @app.terminal_width
95
- end
96
-
97
- def test_no_rakeopt
98
- ARGV << '--trace'
99
- app = Rake::Application.new
100
- app.init
101
- assert !app.options.silent
102
- end
103
-
104
- def test_rakeopt_with_blank_options
105
- ARGV << '--trace'
106
- app = Rake::Application.new
107
- app.init
108
- assert !app.options.silent
109
- end
110
-
111
- def test_rakeopt_with_silent_options
112
- ENV['RAKEOPT'] = '-s'
113
- app = Rake::Application.new
114
-
115
- app.init
116
-
117
- assert app.options.silent
118
- end
119
- end
@@ -1,127 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- ######################################################################
4
- class TestRakeTaskArguments < Rake::TestCase
5
- def teardown
6
- ENV.delete('rev')
7
- ENV.delete('VER')
8
-
9
- super
10
- end
11
-
12
- def test_empty_arg_list_is_empty
13
- ta = Rake::TaskArguments.new([], [])
14
- assert_equal({}, ta.to_hash)
15
- end
16
-
17
- def test_multiple_values_in_args
18
- ta = Rake::TaskArguments.new([:a, :b, :c], [:one, :two, :three])
19
- assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash)
20
- end
21
-
22
- def test_has_key
23
- ta = Rake::TaskArguments.new([:a], [:one])
24
- assert(ta.has_key?(:a))
25
- refute(ta.has_key?(:b))
26
- end
27
-
28
- def test_to_s
29
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
30
- assert_equal ta.to_hash.inspect, ta.to_s
31
- assert_equal ta.to_hash.inspect, ta.inspect
32
- end
33
-
34
- def test_enumerable_behavior
35
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
36
- assert_equal [10, 20, 30], ta.map { |k, v| v * 10 }.sort
37
- end
38
-
39
- def test_named_args
40
- ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
41
- assert_equal 1, ta.aa
42
- assert_equal 1, ta[:aa]
43
- assert_equal 1, ta["aa"]
44
- assert_equal 2, ta.bb
45
- assert_nil ta.cc
46
- end
47
-
48
- def test_args_knows_its_names
49
- ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
50
- assert_equal ["aa", "bb"], ta.names
51
- end
52
-
53
- def test_extra_names_are_nil
54
- ta = Rake::TaskArguments.new(["aa", "bb", "cc"], [1, 2])
55
- assert_nil ta.cc
56
- end
57
-
58
- def test_args_do_not_reference_env_values
59
- ta = Rake::TaskArguments.new(["aa"], [1])
60
- ENV['rev'] = "1.2"
61
- ENV['VER'] = "2.3"
62
- assert_nil ta.rev
63
- assert_nil ta.ver
64
- end
65
-
66
- def test_creating_new_argument_scopes
67
- parent = Rake::TaskArguments.new(['p'], [1])
68
- child = parent.new_scope(['c', 'p'])
69
- assert_equal({:p=>1}, child.to_hash)
70
- assert_equal 1, child.p
71
- assert_equal 1, child["p"]
72
- assert_equal 1, child[:p]
73
- assert_nil child.c
74
- end
75
-
76
- def test_child_hides_parent_arg_names
77
- parent = Rake::TaskArguments.new(['aa'], [1])
78
- child = Rake::TaskArguments.new(['aa'], [2], parent)
79
- assert_equal 2, child.aa
80
- end
81
-
82
- def test_default_arguments_values_can_be_merged
83
- ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
84
- ta.with_defaults({ :aa => 'default_val' })
85
- assert_equal 'default_val', ta[:aa]
86
- assert_equal 'original_val', ta[:bb]
87
- end
88
-
89
- def test_default_arguments_that_dont_match_names_are_ignored
90
- ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
91
- ta.with_defaults({ "cc" => "default_val" })
92
- assert_nil ta[:cc]
93
- end
94
-
95
- def test_all_and_extra_arguments_without_named_arguments
96
- app = Rake::Application.new
97
- _, args = app.parse_task_string("task[1,two,more]")
98
- ta = Rake::TaskArguments.new([], args)
99
- assert_equal [], ta.names
100
- assert_equal ['1', 'two', 'more'], ta.to_a
101
- assert_equal ['1', 'two', 'more'], ta.extras
102
- end
103
-
104
- def test_all_and_extra_arguments_with_named_arguments
105
- app = Rake::Application.new
106
- _, args = app.parse_task_string("task[1,two,more,still more]")
107
- ta = Rake::TaskArguments.new([:first, :second], args)
108
- assert_equal [:first, :second], ta.names
109
- assert_equal "1", ta[:first]
110
- assert_equal "two", ta[:second]
111
- assert_equal ['1', 'two', 'more', 'still more'], ta.to_a
112
- assert_equal ['more', 'still more'], ta.extras
113
- end
114
-
115
- def test_extra_args_with_less_than_named_arguments
116
- app = Rake::Application.new
117
- _, args = app.parse_task_string("task[1,two]")
118
- ta = Rake::TaskArguments.new([:first, :second, :third], args)
119
- assert_equal [:first, :second, :third], ta.names
120
- assert_equal "1", ta[:first]
121
- assert_equal "two", ta[:second]
122
- assert_equal nil, ta[:third]
123
- assert_equal ['1', 'two'], ta.to_a
124
- assert_equal [], ta.extras
125
- end
126
-
127
- end
@@ -1,9 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'rake/tasklib'
3
-
4
- class TestRakeTaskLib < Rake::TestCase
5
- def test_paste
6
- tl = Rake::TaskLib.new
7
- assert_equal :ab, tl.paste(:a, :b)
8
- end
9
- end