rake 10.5.0 → 13.0.6

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 +131 -90
  9. data/lib/rake/backtrace.rb +3 -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 +5 -11
  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 +12 -4
  21. data/lib/rake/file_utils.rb +38 -32
  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 +35 -43
  51. data/rake.gemspec +100 -0
  52. metadata +27 -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,670 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'pathname'
3
-
4
- class TestRakeFileList < Rake::TestCase
5
- FileList = Rake::FileList
6
-
7
- def setup
8
- super
9
-
10
- FileUtils.mkdir "CVS" rescue nil
11
- FileUtils.mkdir ".svn" rescue nil
12
- @cdir = "cfiles"
13
- FileUtils.mkdir @cdir rescue nil
14
- FileUtils.touch ".dummy"
15
- FileUtils.touch "x.bak"
16
- FileUtils.touch "x~"
17
- FileUtils.touch "core"
18
- FileUtils.touch "x.c"
19
- FileUtils.touch "xyz.c"
20
- FileUtils.touch "abc.c"
21
- FileUtils.touch "abc.h"
22
- FileUtils.touch "abc.x"
23
- FileUtils.touch "existing"
24
-
25
- open 'xyzzy.txt', 'w' do |io|
26
- io.puts 'x'
27
- io.puts 'XYZZY'
28
- end
29
-
30
- end
31
-
32
- def test_delegating_methods_do_not_include_to_a_or_to_ary
33
- assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
34
- assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
35
- assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
36
- assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary"
37
- end
38
-
39
- def test_create
40
- fl = FileList.new
41
- assert_equal 0, fl.size
42
- end
43
-
44
- def test_create_with_args
45
- fl = FileList.new("*.c", "x")
46
- assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
47
- fl.sort
48
- end
49
-
50
- def test_create_with_pathname
51
- fl = FileList.new(Pathname.new("*.c"))
52
- assert_equal ["abc.c", "x.c", "xyz.c"].sort,
53
- fl.sort
54
- end
55
-
56
- def test_create_with_block
57
- fl = FileList.new { |f| f.include("x") }
58
- assert_equal ["x"], fl.resolve
59
- end
60
-
61
- def test_create_with_brackets
62
- fl = FileList["*.c", "x"]
63
- assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
64
- fl.sort
65
- end
66
-
67
- def test_create_with_brackets_and_filelist
68
- fl = FileList[FileList["*.c", "x"]]
69
- assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
70
- fl.sort
71
- end
72
-
73
- def test_include_with_another_array
74
- fl = FileList.new.include(["x", "y", "z"])
75
- assert_equal ["x", "y", "z"].sort, fl.sort
76
- end
77
-
78
- def test_include_with_another_filelist
79
- fl = FileList.new.include(FileList["*.c", "x"])
80
- assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
81
- fl.sort
82
- end
83
-
84
- def test_include_with_pathname
85
- fl = FileList.new.include(Pathname.new("*.c"))
86
- assert_equal ["abc.c", "x.c", "xyz.c"].sort,
87
- fl.sort
88
- end
89
-
90
- def test_append
91
- fl = FileList.new
92
- fl << "a.rb" << "b.rb"
93
- assert_equal ['a.rb', 'b.rb'], fl
94
- end
95
-
96
- def test_append_pathname
97
- fl = FileList.new
98
- fl << Pathname.new("a.rb")
99
- assert_equal ['a.rb'], fl
100
- end
101
-
102
- def test_add_many
103
- fl = FileList.new
104
- fl.include %w(a d c)
105
- fl.include('x', 'y')
106
- assert_equal ['a', 'd', 'c', 'x', 'y'], fl
107
- assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve
108
- end
109
-
110
- def test_add_return
111
- f = FileList.new
112
- g = f << "x"
113
- assert_equal f.object_id, g.object_id
114
- h = f.include("y")
115
- assert_equal f.object_id, h.object_id
116
- end
117
-
118
- def test_match
119
- fl = FileList.new
120
- fl.include '*.c'
121
-
122
- assert_equal %w[abc.c x.c xyz.c], fl.sort
123
- end
124
-
125
- def test_add_matching
126
- fl = FileList.new
127
- fl << "a.java"
128
- fl.include '*.c'
129
-
130
- assert_equal %w[a.java abc.c x.c xyz.c], fl.sort
131
- end
132
-
133
- def test_multiple_patterns
134
- fl = FileList.new
135
- fl.include('*.z', '*foo*')
136
-
137
- assert_equal [], fl
138
-
139
- fl.include('*.c', '*xist*')
140
- assert_equal %w[x.c xyz.c abc.c existing].sort, fl.sort
141
- end
142
-
143
- def test_square_bracket_pattern
144
- fl = FileList.new
145
- fl.include("abc.[ch]")
146
- assert fl.size == 2
147
- assert fl.include?("abc.c")
148
- assert fl.include?("abc.h")
149
- end
150
-
151
- def test_curly_bracket_pattern
152
- fl = FileList.new
153
- fl.include("abc.{c,h}")
154
- assert fl.size == 2
155
- assert fl.include?("abc.c")
156
- assert fl.include?("abc.h")
157
- end
158
-
159
- def test_reject
160
- fl = FileList.new
161
- fl.include %w(x.c abc.c xyz.c existing)
162
- fl.reject! { |fn| fn =~ /^x/ }
163
- assert_equal %w[abc.c existing], fl
164
- end
165
-
166
- def test_exclude
167
- fl = FileList['x.c', 'abc.c', 'xyz.c', 'existing']
168
- fl.each { |fn| touch fn, :verbose => false }
169
-
170
- x = fl.exclude(%r{^x.+\.})
171
-
172
- assert_equal FileList, x.class
173
- assert_equal %w(x.c abc.c existing), fl
174
- assert_equal fl.object_id, x.object_id
175
-
176
- fl.exclude('*.c')
177
-
178
- assert_equal ['existing'], fl
179
-
180
- fl.exclude('existing')
181
-
182
- assert_equal [], fl
183
- end
184
-
185
- def test_exclude_pathname
186
- fl = FileList['x.c', 'abc.c', 'other']
187
- fl.each { |fn| touch fn, :verbose => false }
188
-
189
- fl.exclude(Pathname.new('*.c'))
190
-
191
- assert_equal ['other'], fl
192
- end
193
-
194
- def test_excluding_via_block
195
- fl = FileList['a.c', 'b.c', 'xyz.c']
196
- fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
197
- assert fl.excluded_from_list?("xyz.c"), "Should exclude xyz.c"
198
- assert_equal ['a.c', 'b.c'], fl
199
- end
200
-
201
- def test_exclude_return_on_create
202
- fl = FileList['*'].exclude(/.*\.[hcx]$/)
203
- assert_equal %w[cfiles existing xyzzy.txt], fl.sort
204
- assert_equal FileList, fl.class
205
- end
206
-
207
- def test_exclude_with_string_return_on_create
208
- fl = FileList['*'].exclude('abc.c')
209
- assert_equal %w[abc.h abc.x cfiles existing x.c xyz.c xyzzy.txt], fl.sort
210
- assert_equal FileList, fl.class
211
- end
212
-
213
- def test_default_exclude
214
- fl = FileList.new
215
- fl.clear_exclude
216
- fl.include("**/*~", "**/*.bak", "**/core")
217
- assert fl.member?("core"), "Should include core"
218
- assert fl.member?("x.bak"), "Should include .bak files"
219
- end
220
-
221
- def test_unique
222
- fl = FileList.new
223
- fl << "x.c" << "a.c" << "b.rb" << "a.c"
224
- assert_equal ['x.c', 'a.c', 'b.rb', 'a.c'], fl
225
- fl.uniq!
226
- assert_equal ['x.c', 'a.c', 'b.rb'], fl
227
- end
228
-
229
- def test_to_string
230
- fl = FileList.new
231
- fl << "a.java" << "b.java"
232
- assert_equal "a.java b.java", fl.to_s
233
- assert_equal "a.java b.java", "#{fl}"
234
- end
235
-
236
- def test_to_array
237
- fl = FileList['a.java', 'b.java']
238
- assert_equal ['a.java', 'b.java'], fl.to_a
239
- assert_equal Array, fl.to_a.class
240
- assert_equal ['a.java', 'b.java'], fl.to_ary
241
- assert_equal Array, fl.to_ary.class
242
- end
243
-
244
- def test_to_s_pending
245
- fl = FileList['abc.*']
246
- result = fl.to_s
247
- assert_match(%r{abc\.c}, result)
248
- assert_match(%r{abc\.h}, result)
249
- assert_match(%r{abc\.x}, result)
250
- assert_match(%r{(abc\..\b ?){2}}, result)
251
- end
252
-
253
- def test_inspect_pending
254
- fl = FileList['abc.*']
255
- result = fl.inspect
256
- assert_match(%r{"abc\.c"}, result)
257
- assert_match(%r{"abc\.h"}, result)
258
- assert_match(%r{"abc\.x"}, result)
259
- assert_match(%r|^\[("abc\..", ){2}"abc\.."\]$|, result)
260
- end
261
-
262
- def test_sub
263
- fl = FileList["*.c"]
264
- f2 = fl.sub(/\.c$/, ".o")
265
- assert_equal FileList, f2.class
266
- assert_equal ["abc.o", "x.o", "xyz.o"].sort,
267
- f2.sort
268
- f3 = fl.gsub(/\.c$/, ".o")
269
- assert_equal FileList, f3.class
270
- assert_equal ["abc.o", "x.o", "xyz.o"].sort,
271
- f3.sort
272
- end
273
-
274
- def test_claim_to_be_a_kind_of_array
275
- fl = FileList['*.c']
276
- assert fl.is_a?(Array)
277
- assert fl.kind_of?(Array)
278
- end
279
-
280
- def test_claim_to_be_a_kind_of_filelist
281
- fl = FileList['*.c']
282
- assert fl.is_a?(FileList)
283
- assert fl.kind_of?(FileList)
284
- end
285
-
286
- def test_claim_to_be_a_filelist_instance
287
- fl = FileList['*.c']
288
- assert fl.instance_of?(FileList)
289
- end
290
-
291
- def test_dont_claim_to_be_an_array_instance
292
- fl = FileList['*.c']
293
- assert ! fl.instance_of?(Array)
294
- end
295
-
296
- def test_sub!
297
- f = "x/a.c"
298
- fl = FileList[f, "x/b.c"]
299
- res = fl.sub!(/\.c$/, ".o")
300
- assert_equal ["x/a.o", "x/b.o"].sort, fl.sort
301
- assert_equal "x/a.c", f
302
- assert_equal fl.object_id, res.object_id
303
- end
304
-
305
- def test_sub_with_block
306
- fl = FileList["src/org/onestepback/a.java", "src/org/onestepback/b.java"]
307
- # The block version doesn't work the way I want it to ...
308
- # f2 = fl.sub(%r{^src/(.*)\.java$}) { |x| "classes/" + $1 + ".class" }
309
- f2 = fl.sub(%r{^src/(.*)\.java$}, "classes/\\1.class")
310
- assert_equal [
311
- "classes/org/onestepback/a.class",
312
- "classes/org/onestepback/b.class"
313
- ].sort,
314
- f2.sort
315
- end
316
-
317
- def test_string_ext
318
- assert_equal "one.net", "one.two".ext("net")
319
- assert_equal "one.net", "one.two".ext(".net")
320
- assert_equal "one.net", "one".ext("net")
321
- assert_equal "one.net", "one".ext(".net")
322
- assert_equal "one.two.net", "one.two.c".ext(".net")
323
- assert_equal "one/two.net", "one/two.c".ext(".net")
324
- assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
325
- assert_equal "one.x/two.net", "one.x/two".ext(".net")
326
- assert_equal ".onerc.net", ".onerc.dot".ext("net")
327
- assert_equal ".onerc.net", ".onerc".ext("net")
328
- assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
329
- assert_equal "one", "one.two".ext('')
330
- assert_equal "one", "one.two".ext
331
- assert_equal ".one", ".one.two".ext
332
- assert_equal ".one", ".one".ext
333
- assert_equal ".", ".".ext("c")
334
- assert_equal "..", "..".ext("c")
335
- # These only need to work in windows
336
- if Rake::Win32.windows?
337
- assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
338
- assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
339
- end
340
- end
341
-
342
- def test_filelist_ext
343
- assert_equal FileList['one.c', '.one.c'],
344
- FileList['one.net', '.one'].ext('c')
345
- end
346
-
347
- def test_gsub
348
- fl = FileList["*.c"]
349
- f2 = fl.gsub(/a/, "A")
350
- assert_equal ["Abc.c", "x.c", "xyz.c"].sort,
351
- f2.sort
352
- end
353
-
354
- def test_gsub!
355
- f = FileList["*.c"]
356
- f.gsub!(/a/, "A")
357
- assert_equal ["Abc.c", "x.c", "xyz.c"].sort,
358
- f.sort
359
- end
360
-
361
- def test_egrep_returns_0_if_no_matches
362
- files = FileList['test/lib/*_test.rb'].exclude("test/lib/filelist_test.rb")
363
- assert_equal 0, files.egrep(/XYZZY/) { }
364
- end
365
-
366
- def test_egrep_with_output
367
- files = FileList['*.txt']
368
-
369
- out, = capture_io do
370
- files.egrep(/XYZZY/)
371
- end
372
-
373
- assert_equal "xyzzy.txt:2:XYZZY\n", out
374
- end
375
-
376
- def test_egrep_with_block
377
- files = FileList['*.txt']
378
- found = nil
379
-
380
- files.egrep(/XYZZY/) do |fn, ln, line|
381
- found = [fn, ln, line]
382
- end
383
-
384
- assert_equal ["xyzzy.txt", 2, "XYZZY\n"], found
385
- end
386
-
387
- def test_egrep_with_error
388
- files = FileList['*.txt']
389
-
390
- _, err = capture_io do
391
- files.egrep(/XYZZY/) do |fn, ln, line |
392
- raise "_EGREP_FAILURE_"
393
- end
394
- end
395
-
396
- assert_equal "Error while processing 'xyzzy.txt': _EGREP_FAILURE_\n", err
397
- end
398
-
399
- def test_existing
400
- fl = FileList['abc.c', 'notthere.c']
401
- assert_equal ["abc.c"], fl.existing
402
- assert fl.existing.is_a?(FileList)
403
- end
404
-
405
- def test_existing!
406
- fl = FileList['abc.c', 'notthere.c']
407
- result = fl.existing!
408
- assert_equal ["abc.c"], fl
409
- assert_equal fl.object_id, result.object_id
410
- end
411
-
412
- def test_ignore_special
413
- f = FileList['*']
414
- assert ! f.include?("CVS"), "Should not contain CVS"
415
- assert ! f.include?(".svn"), "Should not contain .svn"
416
- assert ! f.include?(".dummy"), "Should not contain dot files"
417
- assert ! f.include?("x.bak"), "Should not contain .bak files"
418
- assert ! f.include?("x~"), "Should not contain ~ files"
419
- assert ! f.include?("core"), "Should not contain core files"
420
- end
421
-
422
- def test_clear_ignore_patterns
423
- f = FileList['*', '.svn']
424
- f.clear_exclude
425
- assert f.include?("abc.c")
426
- assert f.include?("xyz.c")
427
- assert f.include?("CVS")
428
- assert f.include?(".svn")
429
- assert f.include?("x.bak")
430
- assert f.include?("x~")
431
- end
432
-
433
- def test_exclude_with_alternate_file_seps
434
- fl = FileList.new
435
- assert fl.excluded_from_list?("x/CVS/y")
436
- assert fl.excluded_from_list?("x\\CVS\\y")
437
- assert fl.excluded_from_list?("x/.svn/y")
438
- assert fl.excluded_from_list?("x\\.svn\\y")
439
- assert fl.excluded_from_list?("x/core")
440
- assert fl.excluded_from_list?("x\\core")
441
- end
442
-
443
- def test_add_default_exclude_list
444
- fl = FileList.new
445
- fl.exclude(/~\d+$/)
446
- assert fl.excluded_from_list?("x/CVS/y")
447
- assert fl.excluded_from_list?("x\\CVS\\y")
448
- assert fl.excluded_from_list?("x/.svn/y")
449
- assert fl.excluded_from_list?("x\\.svn\\y")
450
- assert fl.excluded_from_list?("x/core")
451
- assert fl.excluded_from_list?("x\\core")
452
- assert fl.excluded_from_list?("x/abc~1")
453
- end
454
-
455
- def test_basic_array_functions
456
- f = FileList['b', 'c', 'a']
457
- assert_equal 'b', f.first
458
- assert_equal 'b', f[0]
459
- assert_equal 'a', f.last
460
- assert_equal 'a', f[2]
461
- assert_equal 'a', f[-1]
462
- assert_equal ['a', 'b', 'c'], f.sort
463
- f.sort!
464
- assert_equal ['a', 'b', 'c'], f
465
- end
466
-
467
- def test_flatten
468
- assert_equal ['a', 'x.c', 'xyz.c', 'abc.c'].sort,
469
- ['a', FileList['*.c']].flatten.sort
470
- end
471
-
472
- def test_clone_and_dup
473
- a = FileList['a', 'b', 'c']
474
- c = a.clone
475
- d = a.dup
476
- a << 'd'
477
- assert_equal ['a', 'b', 'c', 'd'], a
478
- assert_equal ['a', 'b', 'c'], c
479
- assert_equal ['a', 'b', 'c'], d
480
- end
481
-
482
- def test_dup_and_clone_replicate_taint
483
- a = FileList['a', 'b', 'c']
484
- a.taint
485
- c = a.clone
486
- d = a.dup
487
- assert c.tainted?, "Clone should be tainted"
488
- assert d.tainted?, "Dup should be tainted"
489
- end
490
-
491
- def test_duped_items_will_thaw
492
- a = FileList['a', 'b', 'c']
493
- a.freeze
494
- d = a.dup
495
- d << 'more'
496
- assert_equal ['a', 'b', 'c', 'more'], d
497
- end
498
-
499
- def test_cloned_items_stay_frozen
500
- a = FileList['a', 'b', 'c']
501
- a.freeze
502
- c = a.clone
503
- assert_raises(TypeError, RuntimeError) do
504
- c << 'more'
505
- end
506
- end
507
-
508
- def test_array_comparisons
509
- fl = FileList['b', 'b']
510
- a = ['b', 'a']
511
- b = ['b', 'b']
512
- c = ['b', 'c']
513
- assert_equal(1, fl <=> a)
514
- assert_equal(0, fl <=> b)
515
- assert_equal(-1, fl <=> c)
516
- assert_equal(-1, a <=> fl)
517
- assert_equal(0, b <=> fl)
518
- assert_equal(1, c <=> fl)
519
- end
520
-
521
- def test_array_equality
522
- a = FileList['a', 'b']
523
- b = ['a', 'b']
524
- assert a == b
525
- assert b == a
526
- # assert a.eql?(b)
527
- # assert b.eql?(a)
528
- assert ! a.equal?(b)
529
- assert ! b.equal?(a)
530
- end
531
-
532
- def test_enumeration_methods
533
- a = FileList['a', 'b']
534
- b = a.map { |it| it.upcase }
535
- assert_equal ['A', 'B'], b
536
- assert_equal FileList, b.class
537
-
538
- b = a.map { |it| it.upcase }
539
- assert_equal ['A', 'B'], b
540
- assert_equal FileList, b.class
541
-
542
- b = a.sort
543
- assert_equal ['a', 'b'], b
544
- assert_equal FileList, b.class
545
-
546
- b = a.sort_by { |it| it }
547
- assert_equal ['a', 'b'], b
548
- assert_equal FileList, b.class
549
-
550
- b = a.select { |it| it == 'b' }
551
- assert_equal ['b'], b
552
- assert_equal FileList, b.class
553
-
554
- b = a.select { |it| it.size == 1 }
555
- assert_equal ['a', 'b'], b
556
- assert_equal FileList, b.class
557
-
558
- b = a.reject { |it| it == 'b' }
559
- assert_equal ['a'], b
560
- assert_equal FileList, b.class
561
-
562
- b = a.grep(/./)
563
- assert_equal ['a', 'b'], b
564
- assert_equal FileList, b.class
565
-
566
- b = a.partition { |it| it == 'b' }
567
- assert_equal [['b'], ['a']], b
568
- assert_equal Array, b.class
569
- assert_equal FileList, b[0].class
570
- assert_equal FileList, b[1].class
571
-
572
- b = a.zip(['x', 'y']).to_a
573
- assert_equal [['a', 'x'], ['b', 'y']], b
574
- assert_equal Array, b.class
575
- assert_equal Array, b[0].class
576
- assert_equal Array, b[1].class
577
- end
578
-
579
- def test_array_operators
580
- a = ['a', 'b']
581
- b = ['c', 'd']
582
- f = FileList['x', 'y']
583
- g = FileList['w', 'z']
584
-
585
- r = f + g
586
- assert_equal ['x', 'y', 'w', 'z'], r
587
- assert_equal FileList, r.class
588
-
589
- r = a + g
590
- assert_equal ['a', 'b', 'w', 'z'], r
591
- assert_equal Array, r.class
592
-
593
- r = f + b
594
- assert_equal ['x', 'y', 'c', 'd'], r
595
- assert_equal FileList, r.class
596
-
597
- r = FileList['w', 'x', 'y', 'z'] - f
598
- assert_equal ['w', 'z'], r
599
- assert_equal FileList, r.class
600
-
601
- r = FileList['w', 'x', 'y', 'z'] & f
602
- assert_equal ['x', 'y'], r
603
- assert_equal FileList, r.class
604
-
605
- r = f * 2
606
- assert_equal ['x', 'y', 'x', 'y'], r
607
- assert_equal FileList, r.class
608
-
609
- r = f * ','
610
- assert_equal 'x,y', r
611
- assert_equal String, r.class
612
-
613
- r = f | ['a', 'x']
614
- assert_equal ['a', 'x', 'y'].sort, r.sort
615
- assert_equal FileList, r.class
616
- end
617
-
618
- def test_other_array_returning_methods
619
- f = FileList['a', nil, 'b']
620
- r = f.compact
621
- assert_equal ['a', 'b'], r
622
- assert_equal FileList, r.class
623
-
624
- f = FileList['a', 'b']
625
- r = f.concat(['x', 'y'])
626
- assert_equal ['a', 'b', 'x', 'y'], r
627
- assert_equal FileList, r.class
628
-
629
- f = FileList['a', ['b', 'c'], FileList['d', 'e']]
630
- r = f.flatten
631
- assert_equal ['a', 'b', 'c', 'd', 'e'], r
632
- assert_equal FileList, r.class
633
-
634
- f = FileList['a', 'b', 'a']
635
- r = f.uniq
636
- assert_equal ['a', 'b'], r
637
- assert_equal FileList, r.class
638
-
639
- f = FileList['a', 'b', 'c', 'd']
640
- r = f.values_at(1, 3)
641
- assert_equal ['b', 'd'], r
642
- assert_equal FileList, r.class
643
- end
644
-
645
- def test_special_return_delegating_methods_object_type
646
- custom_file_list = Class.new(FileList)
647
- f = custom_file_list.new
648
-
649
- FileList::SPECIAL_RETURN.each do |m|
650
- r = if [].method(m).arity == 1
651
- f.send(m, [])
652
- else
653
- f.send(m)
654
- end
655
-
656
- assert_equal custom_file_list, r.class
657
- end
658
- end
659
-
660
- def test_file_utils_can_use_filelists
661
- cfiles = FileList['*.c']
662
-
663
- cp cfiles, @cdir, :verbose => false
664
-
665
- assert File.exist?(File.join(@cdir, 'abc.c'))
666
- assert File.exist?(File.join(@cdir, 'xyz.c'))
667
- assert File.exist?(File.join(@cdir, 'x.c'))
668
- end
669
-
670
- end
@@ -1,8 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeFileListPathMap < Rake::TestCase
4
- def test_file_list_supports_pathmap
5
- assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
6
- end
7
- end
8
-