elliottcable-echoe 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANGELOG +69 -0
  2. data/LICENSE +184 -0
  3. data/MIT-LICENSE +21 -0
  4. data/Manifest +113 -0
  5. data/README +114 -0
  6. data/Rakefile +15 -0
  7. data/TODO +4 -0
  8. data/echoe.gemspec +37 -0
  9. data/lib/echoe/client.rb +25 -0
  10. data/lib/echoe/extensions.rb +57 -0
  11. data/lib/echoe/platform.rb +36 -0
  12. data/lib/echoe/rubygems.rb +41 -0
  13. data/lib/echoe.rb +717 -0
  14. data/vendor/rake/CHANGES +400 -0
  15. data/vendor/rake/MIT-LICENSE +21 -0
  16. data/vendor/rake/README +285 -0
  17. data/vendor/rake/Rakefile +418 -0
  18. data/vendor/rake/TODO +20 -0
  19. data/vendor/rake/bin/rake +31 -0
  20. data/vendor/rake/doc/example/Rakefile1 +38 -0
  21. data/vendor/rake/doc/example/Rakefile2 +35 -0
  22. data/vendor/rake/doc/example/a.c +6 -0
  23. data/vendor/rake/doc/example/b.c +6 -0
  24. data/vendor/rake/doc/example/main.c +11 -0
  25. data/vendor/rake/doc/glossary.rdoc +51 -0
  26. data/vendor/rake/doc/jamis.rb +591 -0
  27. data/vendor/rake/doc/proto_rake.rdoc +127 -0
  28. data/vendor/rake/doc/rake.1.gz +0 -0
  29. data/vendor/rake/doc/rakefile.rdoc +534 -0
  30. data/vendor/rake/doc/rational.rdoc +151 -0
  31. data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
  32. data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
  33. data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
  34. data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
  35. data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
  36. data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
  37. data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
  38. data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
  39. data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
  40. data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
  41. data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
  42. data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
  43. data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
  44. data/vendor/rake/install.rb +88 -0
  45. data/vendor/rake/lib/rake/classic_namespace.rb +8 -0
  46. data/vendor/rake/lib/rake/clean.rb +33 -0
  47. data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
  48. data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
  49. data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
  50. data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  51. data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
  52. data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
  53. data/vendor/rake/lib/rake/gempackagetask.rb +103 -0
  54. data/vendor/rake/lib/rake/loaders/makefile.rb +35 -0
  55. data/vendor/rake/lib/rake/packagetask.rb +185 -0
  56. data/vendor/rake/lib/rake/rake_test_loader.rb +5 -0
  57. data/vendor/rake/lib/rake/rdoctask.rb +147 -0
  58. data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +23 -0
  59. data/vendor/rake/lib/rake/runtest.rb +23 -0
  60. data/vendor/rake/lib/rake/tasklib.rb +23 -0
  61. data/vendor/rake/lib/rake/testtask.rb +161 -0
  62. data/vendor/rake/lib/rake/win32.rb +54 -0
  63. data/vendor/rake/lib/rake.rb +2468 -0
  64. data/vendor/rake/test/capture_stdout.rb +26 -0
  65. data/vendor/rake/test/check_expansion.rb +5 -0
  66. data/vendor/rake/test/contrib/test_sys.rb +47 -0
  67. data/vendor/rake/test/data/chains/Rakefile +15 -0
  68. data/vendor/rake/test/data/default/Rakefile +19 -0
  69. data/vendor/rake/test/data/dryrun/Rakefile +22 -0
  70. data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
  71. data/vendor/rake/test/data/imports/Rakefile +19 -0
  72. data/vendor/rake/test/data/imports/deps.mf +1 -0
  73. data/vendor/rake/test/data/multidesc/Rakefile +17 -0
  74. data/vendor/rake/test/data/namespace/Rakefile +57 -0
  75. data/vendor/rake/test/data/rakelib/test1.rb +3 -0
  76. data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
  77. data/vendor/rake/test/data/sample.mf +12 -0
  78. data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
  79. data/vendor/rake/test/data/unittest/Rakefile +1 -0
  80. data/vendor/rake/test/filecreation.rb +32 -0
  81. data/vendor/rake/test/functional.rb +15 -0
  82. data/vendor/rake/test/in_environment.rb +30 -0
  83. data/vendor/rake/test/rake_test_setup.rb +10 -0
  84. data/vendor/rake/test/reqfile.rb +3 -0
  85. data/vendor/rake/test/reqfile2.rb +3 -0
  86. data/vendor/rake/test/session_functional.rb +337 -0
  87. data/vendor/rake/test/shellcommand.rb +3 -0
  88. data/vendor/rake/test/test_application.rb +694 -0
  89. data/vendor/rake/test/test_clean.rb +14 -0
  90. data/vendor/rake/test/test_definitions.rb +82 -0
  91. data/vendor/rake/test/test_earlytime.rb +35 -0
  92. data/vendor/rake/test/test_extension.rb +63 -0
  93. data/vendor/rake/test/test_file_creation_task.rb +62 -0
  94. data/vendor/rake/test/test_file_task.rb +139 -0
  95. data/vendor/rake/test/test_filelist.rb +618 -0
  96. data/vendor/rake/test/test_fileutils.rb +250 -0
  97. data/vendor/rake/test/test_ftp.rb +59 -0
  98. data/vendor/rake/test/test_invocation_chain.rb +75 -0
  99. data/vendor/rake/test/test_makefile_loader.rb +25 -0
  100. data/vendor/rake/test/test_multitask.rb +45 -0
  101. data/vendor/rake/test/test_namespace.rb +36 -0
  102. data/vendor/rake/test/test_package_task.rb +116 -0
  103. data/vendor/rake/test/test_pathmap.rb +209 -0
  104. data/vendor/rake/test/test_rake.rb +41 -0
  105. data/vendor/rake/test/test_require.rb +33 -0
  106. data/vendor/rake/test/test_rules.rb +347 -0
  107. data/vendor/rake/test/test_task_arguments.rb +89 -0
  108. data/vendor/rake/test/test_task_manager.rb +170 -0
  109. data/vendor/rake/test/test_tasklib.rb +12 -0
  110. data/vendor/rake/test/test_tasks.rb +371 -0
  111. data/vendor/rake/test/test_test_task.rb +75 -0
  112. data/vendor/rake/test/test_top_level_functions.rb +84 -0
  113. data/vendor/rake/test/test_win32.rb +57 -0
  114. metadata +195 -0
@@ -0,0 +1,618 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+
6
+ require 'test/capture_stdout'
7
+
8
+ class TestFileList < Test::Unit::TestCase
9
+ FileList = Rake::FileList
10
+ include CaptureStdout
11
+
12
+ def setup
13
+ create_test_data
14
+ end
15
+
16
+ def teardown
17
+ # FileList.select_default_ignore_patterns
18
+ FileUtils.rm_rf("testdata")
19
+ end
20
+
21
+ def test_delgating_methods_do_not_include_to_a_or_to_ary
22
+ assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
23
+ assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
24
+ assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
25
+ assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary"
26
+ end
27
+
28
+ def test_create
29
+ fl = FileList.new
30
+ assert_equal 0, fl.size
31
+ end
32
+
33
+ def test_create_with_args
34
+ fl = FileList.new("testdata/*.c", "x")
35
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
36
+ fl.sort
37
+ end
38
+
39
+ def test_create_with_block
40
+ fl = FileList.new { |f| f.include("x") }
41
+ assert_equal ["x"], fl.resolve
42
+ end
43
+
44
+ def test_create_with_brackets
45
+ fl = FileList["testdata/*.c", "x"]
46
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
47
+ fl.sort
48
+ end
49
+
50
+ def test_create_with_brackets_and_filelist
51
+ fl = FileList[FileList["testdata/*.c", "x"]]
52
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
53
+ fl.sort
54
+ end
55
+
56
+ def test_include_with_another_array
57
+ fl = FileList.new.include(["x", "y", "z"])
58
+ assert_equal ["x", "y", "z"].sort, fl.sort
59
+ end
60
+
61
+ def test_include_with_another_filelist
62
+ fl = FileList.new.include(FileList["testdata/*.c", "x"])
63
+ assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
64
+ fl.sort
65
+ end
66
+
67
+ def test_append
68
+ fl = FileList.new
69
+ fl << "a.rb" << "b.rb"
70
+ assert_equal ['a.rb', 'b.rb'], fl
71
+ end
72
+
73
+ def test_add_many
74
+ fl = FileList.new
75
+ fl.include %w(a d c)
76
+ fl.include('x', 'y')
77
+ assert_equal ['a', 'd', 'c', 'x', 'y'], fl
78
+ assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve
79
+ end
80
+
81
+ def test_add_return
82
+ f = FileList.new
83
+ g = f << "x"
84
+ assert_equal f.object_id, g.object_id
85
+ h = f.include("y")
86
+ assert_equal f.object_id, h.object_id
87
+ end
88
+
89
+ def test_match
90
+ fl = FileList.new
91
+ fl.include('test/test*.rb')
92
+ assert fl.include?("test/test_filelist.rb")
93
+ assert fl.size > 3
94
+ fl.each { |fn| assert_match(/\.rb$/, fn) }
95
+ end
96
+
97
+ def test_add_matching
98
+ fl = FileList.new
99
+ fl << "a.java"
100
+ fl.include("test/*.rb")
101
+ assert_equal "a.java", fl[0]
102
+ assert fl.size > 2
103
+ assert fl.include?("test/test_filelist.rb")
104
+ end
105
+
106
+ def test_multiple_patterns
107
+ create_test_data
108
+ fl = FileList.new
109
+ fl.include('*.c', '*xist*')
110
+ assert_equal [], fl
111
+ fl.include('testdata/*.c', 'testdata/*xist*')
112
+ assert_equal [
113
+ 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c', 'testdata/existing'
114
+ ].sort, fl.sort
115
+ end
116
+
117
+ def test_square_bracket_pattern
118
+ fl = FileList.new
119
+ fl.include("testdata/abc.[ch]")
120
+ assert fl.size == 2
121
+ assert fl.include?("testdata/abc.c")
122
+ assert fl.include?("testdata/abc.h")
123
+ end
124
+
125
+ def test_curly_bracket_pattern
126
+ fl = FileList.new
127
+ fl.include("testdata/abc.{c,h}")
128
+ assert fl.size == 2
129
+ assert fl.include?("testdata/abc.c")
130
+ assert fl.include?("testdata/abc.h")
131
+ end
132
+
133
+ def test_reject
134
+ fl = FileList.new
135
+ fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
136
+ fl.reject! { |fn| fn =~ %r{/x} }
137
+ assert_equal [
138
+ 'testdata/abc.c', 'testdata/existing'
139
+ ], fl
140
+ end
141
+
142
+ def test_exclude
143
+ fl = FileList['testdata/x.c', 'testdata/abc.c', 'testdata/xyz.c', 'testdata/existing']
144
+ fl.each { |fn| touch fn, :verbose => false }
145
+ x = fl.exclude(%r{/x.+\.})
146
+ assert_equal FileList, x.class
147
+ assert_equal %w(testdata/x.c testdata/abc.c testdata/existing), fl
148
+ assert_equal fl.object_id, x.object_id
149
+ fl.exclude('testdata/*.c')
150
+ assert_equal ['testdata/existing'], fl
151
+ fl.exclude('testdata/existing')
152
+ assert_equal [], fl
153
+ end
154
+
155
+ def test_excluding_via_block
156
+ fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
157
+ fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
158
+ assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
159
+ assert_equal ['testdata/a.c', 'testdata/b.c'], fl
160
+ end
161
+
162
+ def test_exclude_return_on_create
163
+ fl = FileList['testdata/*'].exclude(/.*\.[hcx]$/)
164
+ assert_equal ['testdata/existing', 'testdata/cfiles'].sort, fl.sort
165
+ assert_equal FileList, fl.class
166
+ end
167
+
168
+ def test_exclude_with_string_return_on_create
169
+ fl = FileList['testdata/*'].exclude('testdata/abc.c')
170
+ assert_equal %w(testdata/existing testdata/cfiles testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c).sort, fl.sort
171
+ assert_equal FileList, fl.class
172
+ end
173
+
174
+ def test_default_exclude
175
+ fl = FileList.new
176
+ fl.clear_exclude
177
+ fl.include("**/*~", "**/*.bak", "**/core")
178
+ assert fl.member?("testdata/core"), "Should include core"
179
+ assert fl.member?("testdata/x.bak"), "Should include .bak files"
180
+ end
181
+
182
+ def test_unique
183
+ fl = FileList.new
184
+ fl << "x.c" << "a.c" << "b.rb" << "a.c"
185
+ assert_equal ['x.c', 'a.c', 'b.rb', 'a.c'], fl
186
+ fl.uniq!
187
+ assert_equal ['x.c', 'a.c', 'b.rb'], fl
188
+ end
189
+
190
+ def test_to_string
191
+ fl = FileList.new
192
+ fl << "a.java" << "b.java"
193
+ assert_equal "a.java b.java", fl.to_s
194
+ assert_equal "a.java b.java", "#{fl}"
195
+ end
196
+
197
+ def test_to_array
198
+ fl = FileList['a.java', 'b.java']
199
+ assert_equal ['a.java', 'b.java'], fl.to_a
200
+ assert_equal Array, fl.to_a.class
201
+ assert_equal ['a.java', 'b.java'], fl.to_ary
202
+ assert_equal Array, fl.to_ary.class
203
+ end
204
+
205
+ def test_to_s_pending
206
+ fl = FileList['testdata/abc.*']
207
+ result = fl.to_s
208
+ assert_match(%r{testdata/abc\.c}, result)
209
+ assert_match(%r{testdata/abc\.h}, result)
210
+ assert_match(%r{testdata/abc\.x}, result)
211
+ assert_match(%r{(testdata/abc\..\b ?){2}}, result)
212
+ end
213
+
214
+ def test_inspect_pending
215
+ fl = FileList['testdata/abc.*']
216
+ result = fl.inspect
217
+ assert_match(%r{"testdata/abc\.c"}, result)
218
+ assert_match(%r{"testdata/abc\.h"}, result)
219
+ assert_match(%r{"testdata/abc\.x"}, result)
220
+ assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
221
+ end
222
+
223
+ def test_sub
224
+ fl = FileList["testdata/*.c"]
225
+ f2 = fl.sub(/\.c$/, ".o")
226
+ assert_equal FileList, f2.class
227
+ assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
228
+ f2.sort
229
+ f3 = fl.gsub(/\.c$/, ".o")
230
+ assert_equal FileList, f3.class
231
+ assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
232
+ f3.sort
233
+ end
234
+
235
+ def test_claim_to_be_a_kind_of_array
236
+ fl = FileList['testdata/*.c']
237
+ assert fl.is_a?(Array)
238
+ assert fl.kind_of?(Array)
239
+ end
240
+
241
+ def test_claim_to_be_a_kind_of_filelist
242
+ fl = FileList['testdata/*.c']
243
+ assert fl.is_a?(FileList)
244
+ assert fl.kind_of?(FileList)
245
+ end
246
+
247
+ def test_claim_to_be_a_filelist_instance
248
+ fl = FileList['testdata/*.c']
249
+ assert fl.instance_of?(FileList)
250
+ end
251
+
252
+ def test_dont_claim_to_be_an_array_instance
253
+ fl = FileList['testdata/*.c']
254
+ assert ! fl.instance_of?(Array)
255
+ end
256
+
257
+ def test_sub!
258
+ f = "x/a.c"
259
+ fl = FileList[f, "x/b.c"]
260
+ res = fl.sub!(/\.c$/, ".o")
261
+ assert_equal ["x/a.o", "x/b.o"].sort, fl.sort
262
+ assert_equal "x/a.c", f
263
+ assert_equal fl.object_id, res.object_id
264
+ end
265
+
266
+ def test_sub_with_block
267
+ fl = FileList["src/org/onestepback/a.java", "src/org/onestepback/b.java"]
268
+ # The block version doesn't work the way I want it to ...
269
+ # f2 = fl.sub(%r{^src/(.*)\.java$}) { |x| "classes/" + $1 + ".class" }
270
+ f2 = fl.sub(%r{^src/(.*)\.java$}, "classes/\\1.class")
271
+ assert_equal [
272
+ "classes/org/onestepback/a.class",
273
+ "classes/org/onestepback/b.class"
274
+ ].sort,
275
+ f2.sort
276
+ end
277
+
278
+ def test_string_ext
279
+ assert_equal "one.net", "one.two".ext("net")
280
+ assert_equal "one.net", "one.two".ext(".net")
281
+ assert_equal "one.net", "one".ext("net")
282
+ assert_equal "one.net", "one".ext(".net")
283
+ assert_equal "one.two.net", "one.two.c".ext(".net")
284
+ assert_equal "one/two.net", "one/two.c".ext(".net")
285
+ assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
286
+ assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
287
+ assert_equal "one.x/two.net", "one.x/two".ext(".net")
288
+ assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
289
+ assert_equal ".onerc.net", ".onerc.dot".ext("net")
290
+ assert_equal ".onerc.net", ".onerc".ext("net")
291
+ assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
292
+ assert_equal "one", "one.two".ext('')
293
+ assert_equal "one", "one.two".ext
294
+ assert_equal ".one", ".one.two".ext
295
+ assert_equal ".one", ".one".ext
296
+ assert_equal ".", ".".ext("c")
297
+ assert_equal "..", "..".ext("c")
298
+ end
299
+
300
+ def test_filelist_ext
301
+ assert_equal FileList['one.c', '.one.c'],
302
+ FileList['one.net', '.one'].ext('c')
303
+ end
304
+
305
+ def test_gsub
306
+ create_test_data
307
+ fl = FileList["testdata/*.c"]
308
+ f2 = fl.gsub(/a/, "A")
309
+ assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
310
+ f2.sort
311
+ end
312
+
313
+ def test_gsub!
314
+ create_test_data
315
+ f = FileList["testdata/*.c"]
316
+ f.gsub!(/a/, "A")
317
+ assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
318
+ f.sort
319
+ end
320
+
321
+ def test_egrep_with_output
322
+ files = FileList['test/test*.rb']
323
+ the_line_number = __LINE__ + 1
324
+ out = capture_stdout do files.egrep(/PUGH/) end
325
+ assert_match(/:#{the_line_number}:/, out)
326
+ end
327
+
328
+ def test_egrep_with_block
329
+ files = FileList['test/test*.rb']
330
+ found = false
331
+ the_line_number = __LINE__ + 1
332
+ files.egrep(/XYZZY/) do |fn, ln, line |
333
+ assert_equal 'test/test_filelist.rb', fn
334
+ assert_equal the_line_number, ln
335
+ assert_match(/files\.egrep/, line)
336
+ found = true
337
+ end
338
+ assert found, "should have found a matching line"
339
+ end
340
+
341
+ def test_existing
342
+ fl = FileList['testdata/abc.c', 'testdata/notthere.c']
343
+ assert_equal ["testdata/abc.c"], fl.existing
344
+ assert fl.existing.is_a?(FileList)
345
+ end
346
+
347
+ def test_existing!
348
+ fl = FileList['testdata/abc.c', 'testdata/notthere.c']
349
+ result = fl.existing!
350
+ assert_equal ["testdata/abc.c"], fl
351
+ assert_equal fl.object_id, result.object_id
352
+ end
353
+
354
+ def test_ignore_special
355
+ f = FileList['testdata/*']
356
+ assert ! f.include?("testdata/CVS"), "Should not contain CVS"
357
+ assert ! f.include?("testdata/.svn"), "Should not contain .svn"
358
+ assert ! f.include?("testdata/.dummy"), "Should not contain dot files"
359
+ assert ! f.include?("testdata/x.bak"), "Should not contain .bak files"
360
+ assert ! f.include?("testdata/x~"), "Should not contain ~ files"
361
+ assert ! f.include?("testdata/core"), "Should not contain core files"
362
+ end
363
+
364
+ def test_clear_ignore_patterns
365
+ f = FileList['testdata/*', 'testdata/.svn']
366
+ f.clear_exclude
367
+ assert f.include?("testdata/abc.c")
368
+ assert f.include?("testdata/xyz.c")
369
+ assert f.include?("testdata/CVS")
370
+ assert f.include?("testdata/.svn")
371
+ assert f.include?("testdata/x.bak")
372
+ assert f.include?("testdata/x~")
373
+ end
374
+
375
+ def test_exclude_with_alternate_file_seps
376
+ fl = FileList.new
377
+ assert fl.exclude?("x/CVS/y")
378
+ assert fl.exclude?("x\\CVS\\y")
379
+ assert fl.exclude?("x/.svn/y")
380
+ assert fl.exclude?("x\\.svn\\y")
381
+ assert fl.exclude?("x/core")
382
+ assert fl.exclude?("x\\core")
383
+ end
384
+
385
+ def test_add_default_exclude_list
386
+ fl = FileList.new
387
+ fl.exclude(/~\d+$/)
388
+ assert fl.exclude?("x/CVS/y")
389
+ assert fl.exclude?("x\\CVS\\y")
390
+ assert fl.exclude?("x/.svn/y")
391
+ assert fl.exclude?("x\\.svn\\y")
392
+ assert fl.exclude?("x/core")
393
+ assert fl.exclude?("x\\core")
394
+ assert fl.exclude?("x/abc~1")
395
+ end
396
+
397
+ def test_basic_array_functions
398
+ f = FileList['b', 'c', 'a']
399
+ assert_equal 'b', f.first
400
+ assert_equal 'b', f[0]
401
+ assert_equal 'a', f.last
402
+ assert_equal 'a', f[2]
403
+ assert_equal 'a', f[-1]
404
+ assert_equal ['a', 'b', 'c'], f.sort
405
+ f.sort!
406
+ assert_equal ['a', 'b', 'c'], f
407
+ end
408
+
409
+ def test_flatten
410
+ assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
411
+ ['a', FileList['testdata/*.c']].flatten.sort
412
+ end
413
+
414
+ def test_clone_and_dup
415
+ a = FileList['a', 'b', 'c']
416
+ c = a.clone
417
+ d = a.dup
418
+ a << 'd'
419
+ assert_equal ['a', 'b', 'c', 'd'], a
420
+ assert_equal ['a', 'b', 'c'], c
421
+ assert_equal ['a', 'b', 'c'], d
422
+ end
423
+
424
+ def test_dup_and_clone_replicate_taint
425
+ a = FileList['a', 'b', 'c']
426
+ a.taint
427
+ c = a.clone
428
+ d = a.dup
429
+ assert c.tainted?, "Clone should be tainted"
430
+ assert d.tainted?, "Dup should be tainted"
431
+ end
432
+
433
+ def test_duped_items_will_thaw
434
+ a = FileList['a', 'b', 'c']
435
+ a.freeze
436
+ d = a.dup
437
+ d << 'more'
438
+ assert_equal ['a', 'b', 'c', 'more'], d
439
+ end
440
+
441
+ def test_cloned_items_stay_frozen
442
+ a = FileList['a', 'b', 'c']
443
+ a.freeze
444
+ c = a.clone
445
+ assert_raise(TypeError, RuntimeError) do
446
+ c << 'more'
447
+ end
448
+ end
449
+
450
+ def test_array_comparisons
451
+ fl = FileList['b', 'b']
452
+ a = ['b', 'a']
453
+ b = ['b', 'b']
454
+ c = ['b', 'c']
455
+ assert_equal( 1, fl <=> a )
456
+ assert_equal( 0, fl <=> b )
457
+ assert_equal( -1, fl <=> c )
458
+ assert_equal( -1, a <=> fl )
459
+ assert_equal( 0, b <=> fl )
460
+ assert_equal( 1, c <=> fl )
461
+ end
462
+
463
+ def test_array_equality
464
+ a = FileList['a', 'b']
465
+ b = ['a', 'b']
466
+ assert a == b
467
+ assert b == a
468
+ # assert a.eql?(b)
469
+ # assert b.eql?(a)
470
+ assert ! a.equal?(b)
471
+ assert ! b.equal?(a)
472
+ end
473
+
474
+ def test_enumeration_methods
475
+ a = FileList['a', 'b']
476
+ b = a.collect { |it| it.upcase }
477
+ assert_equal ['A', 'B'], b
478
+ assert_equal FileList, b.class
479
+
480
+ b = a.map { |it| it.upcase }
481
+ assert_equal ['A', 'B'], b
482
+ assert_equal FileList, b.class
483
+
484
+ b = a.sort
485
+ assert_equal ['a', 'b'], b
486
+ assert_equal FileList, b.class
487
+
488
+ b = a.sort_by { |it| it }
489
+ assert_equal ['a', 'b'], b
490
+ assert_equal FileList, b.class
491
+
492
+ b = a.find_all { |it| it == 'b'}
493
+ assert_equal ['b'], b
494
+ assert_equal FileList, b.class
495
+
496
+ b = a.select { |it| it.size == 1 }
497
+ assert_equal ['a', 'b'], b
498
+ assert_equal FileList, b.class
499
+
500
+ b = a.reject { |it| it == 'b' }
501
+ assert_equal ['a'], b
502
+ assert_equal FileList, b.class
503
+
504
+ b = a.grep(/./)
505
+ assert_equal ['a', 'b'], b
506
+ assert_equal FileList, b.class
507
+
508
+ b = a.partition { |it| it == 'b' }
509
+ assert_equal [['b'], ['a']], b
510
+ assert_equal Array, b.class
511
+ assert_equal FileList, b[0].class
512
+ assert_equal FileList, b[1].class
513
+
514
+ b = a.zip(['x', 'y']).to_a
515
+ assert_equal [['a', 'x'], ['b', 'y']], b
516
+ assert_equal Array, b.class
517
+ assert_equal Array, b[0].class
518
+ assert_equal Array, b[1].class
519
+ end
520
+
521
+ def test_array_operators
522
+ a = ['a', 'b']
523
+ b = ['c', 'd']
524
+ f = FileList['x', 'y']
525
+ g = FileList['w', 'z']
526
+
527
+ r = f + g
528
+ assert_equal ['x', 'y', 'w', 'z'], r
529
+ assert_equal FileList, r.class
530
+
531
+ r = a + g
532
+ assert_equal ['a', 'b', 'w', 'z'], r
533
+ assert_equal Array, r.class
534
+
535
+ r = f + b
536
+ assert_equal ['x', 'y', 'c', 'd'], r
537
+ assert_equal FileList, r.class
538
+
539
+ r = FileList['w', 'x', 'y', 'z'] - f
540
+ assert_equal ['w', 'z'], r
541
+ assert_equal FileList, r.class
542
+
543
+ r = FileList['w', 'x', 'y', 'z'] & f
544
+ assert_equal ['x', 'y'], r
545
+ assert_equal FileList, r.class
546
+
547
+ r = f * 2
548
+ assert_equal ['x', 'y', 'x', 'y'], r
549
+ assert_equal FileList, r.class
550
+
551
+ r = f * ','
552
+ assert_equal 'x,y', r
553
+ assert_equal String, r.class
554
+
555
+ r = f | ['a', 'x']
556
+ assert_equal ['a', 'x', 'y'].sort, r.sort
557
+ assert_equal FileList, r.class
558
+ end
559
+
560
+ def test_other_array_returning_methods
561
+ f = FileList['a', nil, 'b']
562
+ r = f.compact
563
+ assert_equal ['a', 'b'], r
564
+ assert_equal FileList, r.class
565
+
566
+ f = FileList['a', 'b']
567
+ r = f.concat(['x', 'y'])
568
+ assert_equal ['a', 'b', 'x', 'y'], r
569
+ assert_equal FileList, r.class
570
+
571
+ f = FileList['a', ['b', 'c'], FileList['d', 'e']]
572
+ r = f.flatten
573
+ assert_equal ['a', 'b', 'c', 'd', 'e'], r
574
+ assert_equal FileList, r.class
575
+
576
+ f = FileList['a', 'b', 'a']
577
+ r = f.uniq
578
+ assert_equal ['a', 'b'], r
579
+ assert_equal FileList, r.class
580
+
581
+ f = FileList['a', 'b', 'c', 'd']
582
+ r = f.values_at(1,3)
583
+ assert_equal ['b', 'd'], r
584
+ assert_equal FileList, r.class
585
+ end
586
+
587
+ def test_file_utils_can_use_filelists
588
+ cfiles = FileList['testdata/*.c']
589
+
590
+ cp cfiles, @cdir, :verbose => false
591
+
592
+ assert File.exist?(File.join(@cdir, 'abc.c'))
593
+ assert File.exist?(File.join(@cdir, 'xyz.c'))
594
+ assert File.exist?(File.join(@cdir, 'x.c'))
595
+ end
596
+
597
+ def create_test_data
598
+ verbose(false) do
599
+
600
+ mkdir "testdata" unless File.exist? "testdata"
601
+ mkdir "testdata/CVS" rescue nil
602
+ mkdir "testdata/.svn" rescue nil
603
+ @cdir = "testdata/cfiles"
604
+ mkdir @cdir rescue nil
605
+ touch "testdata/.dummy"
606
+ touch "testdata/x.bak"
607
+ touch "testdata/x~"
608
+ touch "testdata/core"
609
+ touch "testdata/x.c"
610
+ touch "testdata/xyz.c"
611
+ touch "testdata/abc.c"
612
+ touch "testdata/abc.h"
613
+ touch "testdata/abc.x"
614
+ touch "testdata/existing"
615
+ end
616
+ end
617
+
618
+ end