rake 0.9.2 → 0.9.2.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

Files changed (75) hide show
  1. data/CHANGES +13 -0
  2. data/README.rdoc +12 -15
  3. data/Rakefile +8 -44
  4. data/bin/rake +1 -0
  5. data/lib/rake.rb +4 -0
  6. data/lib/rake/application.rb +9 -3
  7. data/lib/rake/classic_namespace.rb +2 -0
  8. data/lib/rake/clean.rb +1 -0
  9. data/lib/rake/contrib/publisher.rb +10 -6
  10. data/lib/rake/contrib/sshpublisher.rb +5 -0
  11. data/lib/rake/dsl_definition.rb +13 -4
  12. data/lib/rake/ext/time.rb +3 -3
  13. data/lib/rake/file_utils.rb +9 -7
  14. data/lib/rake/file_utils_ext.rb +4 -1
  15. data/lib/rake/gempackagetask.rb +2 -0
  16. data/lib/rake/rake_test_loader.rb +15 -6
  17. data/lib/rake/rdoctask.rb +5 -1
  18. data/lib/rake/task_arguments.rb +4 -0
  19. data/lib/rake/version.rb +5 -7
  20. data/test/file_creation.rb +2 -2
  21. data/test/helper.rb +460 -12
  22. data/test/test_rake.rb +3 -1
  23. data/test/test_rake_application.rb +250 -125
  24. data/test/test_rake_application_options.rb +146 -193
  25. data/test/test_rake_clean.rb +2 -0
  26. data/test/test_rake_definitions.rb +6 -6
  27. data/test/test_rake_directory_task.rb +26 -35
  28. data/test/test_rake_dsl.rb +4 -0
  29. data/test/test_rake_file_creation_task.rb +1 -7
  30. data/test/test_rake_file_list.rb +128 -133
  31. data/test/test_rake_file_task.rb +1 -3
  32. data/test/test_rake_file_utils.rb +123 -70
  33. data/test/test_rake_functional.rb +234 -252
  34. data/test/test_rake_makefile_loader.rb +22 -1
  35. data/test/test_rake_package_task.rb +10 -9
  36. data/test/test_rake_path_map_explode.rb +3 -0
  37. data/test/test_rake_pseudo_status.rb +3 -2
  38. data/test/test_rake_rake_test_loader.rb +21 -0
  39. data/test/test_rake_rdoc_task.rb +5 -3
  40. data/test/test_rake_require.rb +8 -3
  41. data/test/test_rake_rules.rb +56 -75
  42. data/test/test_rake_task.rb +5 -9
  43. data/test/test_rake_task_argument_parsing.rb +33 -46
  44. data/test/test_rake_task_arguments.rb +2 -0
  45. data/test/test_rake_task_manager.rb +12 -0
  46. data/test/test_rake_task_with_arguments.rb +11 -0
  47. data/test/test_rake_test_task.rb +55 -57
  48. data/test/test_rake_top_level_functions.rb +52 -17
  49. data/test/test_rake_win32.rb +31 -42
  50. metadata +6 -52
  51. data/RRR +0 -9
  52. data/test/check_expansion.rb +0 -5
  53. data/test/check_no_expansion.rb +0 -5
  54. data/test/data/access/Rakefile +0 -35
  55. data/test/data/chains/Rakefile +0 -15
  56. data/test/data/comments/Rakefile +0 -18
  57. data/test/data/default/Rakefile +0 -17
  58. data/test/data/deprecated_import/Rakefile +0 -1
  59. data/test/data/dryrun/Rakefile +0 -22
  60. data/test/data/extra/Rakefile +0 -1
  61. data/test/data/file_creation_task/Rakefile +0 -31
  62. data/test/data/imports/Rakefile +0 -19
  63. data/test/data/imports/deps.mf +0 -1
  64. data/test/data/multidesc/Rakefile +0 -15
  65. data/test/data/namespace/Rakefile +0 -64
  66. data/test/data/rakelib/test1.rb +0 -4
  67. data/test/data/rbext/rakefile.rb +0 -3
  68. data/test/data/sample.mf +0 -14
  69. data/test/data/statusreturn/Rakefile +0 -6
  70. data/test/data/unittest/Rakefile +0 -1
  71. data/test/data/verbose/Rakefile +0 -34
  72. data/test/in_environment.rb +0 -35
  73. data/test/reqfile.rb +0 -3
  74. data/test/reqfile2.rb +0 -3
  75. data/test/shellcommand.rb +0 -3
@@ -4,6 +4,8 @@ require 'rake/clean'
4
4
  class TestRakeClean < Rake::TestCase
5
5
  include Rake
6
6
  def test_clean
7
+ load 'rake/clean.rb', true
8
+
7
9
  assert Task['clean'], "Should define clean"
8
10
  assert Task['clobber'], "Should define clobber"
9
11
  assert Task['clobber'].prerequisites.include?("clean"),
@@ -4,7 +4,7 @@ require 'fileutils'
4
4
  class TestRakeDefinitions < Rake::TestCase
5
5
  include Rake
6
6
 
7
- EXISTINGFILE = "testdata/existing"
7
+ EXISTINGFILE = "existing"
8
8
 
9
9
  def setup
10
10
  super
@@ -23,10 +23,10 @@ class TestRakeDefinitions < Rake::TestCase
23
23
 
24
24
  def test_file_task
25
25
  done = false
26
- file "testdata/one" => "testdata/two" do done = true end
27
- file "testdata/two"
28
- file "testdata/three" => ["testdata/one", "testdata/two"]
29
- check_tasks("testdata/one", "testdata/two", "testdata/three")
26
+ file "one" => "two" do done = true end
27
+ file "two"
28
+ file "three" => ["one", "two"]
29
+ check_tasks("one", "two", "three")
30
30
  assert done, "Should be done"
31
31
  end
32
32
 
@@ -55,7 +55,7 @@ class TestRakeDefinitions < Rake::TestCase
55
55
  end
56
56
 
57
57
  def test_missing_dependencies
58
- task :x => ["testdata/missing"]
58
+ task :x => ["missing"]
59
59
  assert_raises(RuntimeError) { Task[:x].invoke }
60
60
  end
61
61
 
@@ -4,52 +4,43 @@ require 'fileutils'
4
4
  class TestRakeDirectoryTask < Rake::TestCase
5
5
  include Rake
6
6
 
7
- def setup
8
- super
7
+ def test_directory
8
+ desc "DESC"
9
9
 
10
- Rake.rm_rf "testdata", :verbose=>false
11
- end
10
+ directory "a/b/c"
12
11
 
13
- def teardown
14
- Rake.rm_rf "testdata", :verbose=>false
12
+ assert_equal FileCreationTask, Task["a"].class
13
+ assert_equal FileCreationTask, Task["a/b"].class
14
+ assert_equal FileCreationTask, Task["a/b/c"].class
15
15
 
16
- super
17
- end
16
+ assert_nil Task["a"].comment
17
+ assert_nil Task["a/b"].comment
18
+ assert_equal "DESC", Task["a/b/c"].comment
18
19
 
19
- def test_directory
20
- desc "DESC"
21
- directory "testdata/a/b/c"
22
- assert_equal FileCreationTask, Task["testdata"].class
23
- assert_equal FileCreationTask, Task["testdata/a"].class
24
- assert_equal FileCreationTask, Task["testdata/a/b/c"].class
25
- assert_nil Task["testdata"].comment
26
- assert_equal "DESC", Task["testdata/a/b/c"].comment
27
- assert_nil Task["testdata/a/b"].comment
28
20
  verbose(false) {
29
- Task['testdata/a/b'].invoke
21
+ Task['a/b'].invoke
30
22
  }
31
- assert File.exist?("testdata/a/b")
32
- assert ! File.exist?("testdata/a/b/c")
23
+
24
+ assert File.exist?("a/b")
25
+ refute File.exist?("a/b/c")
33
26
  end
34
27
 
35
28
  if Rake::Win32.windows?
36
29
  def test_directory_win32
37
30
  desc "WIN32 DESC"
38
- FileUtils.mkdir_p("testdata")
39
- Dir.chdir("testdata") do
40
- directory 'c:/testdata/a/b/c'
41
- assert_equal FileCreationTask, Task['c:/testdata'].class
42
- assert_equal FileCreationTask, Task['c:/testdata/a'].class
43
- assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
44
- assert_nil Task['c:/testdata'].comment
45
- assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
46
- assert_nil Task['c:/testdata/a/b'].comment
47
- verbose(false) {
48
- Task['c:/testdata/a/b'].invoke
49
- }
50
- assert File.exist?('c:/testdata/a/b')
51
- assert ! File.exist?('c:/testdata/a/b/c')
52
- end
31
+ directory 'c:/a/b/c'
32
+ assert_equal FileTask, Task['c:'].class
33
+ assert_equal FileCreationTask, Task['c:/a'].class
34
+ assert_equal FileCreationTask, Task['c:/a/b'].class
35
+ assert_equal FileCreationTask, Task['c:/a/b/c'].class
36
+ assert_nil Task['c:/'].comment
37
+ assert_equal "WIN32 DESC", Task['c:/a/b/c'].comment
38
+ assert_nil Task['c:/a/b'].comment
39
+ verbose(false) {
40
+ Task['c:/a/b'].invoke
41
+ }
42
+ assert File.exist?('c:/a/b')
43
+ refute File.exist?('c:/a/b/c')
53
44
  end
54
45
  end
55
46
  end
@@ -56,6 +56,10 @@ class TestRakeDsl < Rake::TestCase
56
56
  assert_match(/test_rake_dsl\.rb:\d+/, err)
57
57
  end
58
58
 
59
+ def test_no_commands_constant
60
+ assert ! defined?(Commands), "should not define Commands"
61
+ end
62
+
59
63
  def test_deprecated_object_dsl_with_suppressed_warnings
60
64
  Rake.application.options.ignore_deprecate = true
61
65
  out, err = capture_io do
@@ -6,7 +6,7 @@ class TestRakeFileCreationTask < Rake::TestCase
6
6
  include Rake
7
7
  include Rake::DSL
8
8
 
9
- DUMMY_DIR = 'testdata/dummy_dir'
9
+ DUMMY_DIR = 'dummy_dir'
10
10
 
11
11
  def setup
12
12
  super
@@ -14,12 +14,6 @@ class TestRakeFileCreationTask < Rake::TestCase
14
14
  Task.clear
15
15
  end
16
16
 
17
- def teardown
18
- FileUtils.rm_rf DUMMY_DIR
19
-
20
- super
21
- end
22
-
23
17
  def test_file_needed
24
18
  create_dir DUMMY_DIR
25
19
  fc_task = Task[DUMMY_DIR]
@@ -6,14 +6,26 @@ class TestRakeFileList < Rake::TestCase
6
6
  def setup
7
7
  super
8
8
 
9
- create_test_data
10
- end
11
-
12
- def teardown
13
- # FileList.select_default_ignore_patterns
14
- FileUtils.rm_rf("testdata")
9
+ FileUtils.mkdir "CVS" rescue nil
10
+ FileUtils.mkdir ".svn" rescue nil
11
+ @cdir = "cfiles"
12
+ FileUtils.mkdir @cdir rescue nil
13
+ FileUtils.touch ".dummy"
14
+ FileUtils.touch "x.bak"
15
+ FileUtils.touch "x~"
16
+ FileUtils.touch "core"
17
+ FileUtils.touch "x.c"
18
+ FileUtils.touch "xyz.c"
19
+ FileUtils.touch "abc.c"
20
+ FileUtils.touch "abc.h"
21
+ FileUtils.touch "abc.x"
22
+ FileUtils.touch "existing"
23
+
24
+ open 'xyzzy.txt', 'w' do |io|
25
+ io.puts 'x'
26
+ io.puts 'XYZZY'
27
+ end
15
28
 
16
- super
17
29
  end
18
30
 
19
31
  def test_delegating_methods_do_not_include_to_a_or_to_ary
@@ -29,8 +41,8 @@ class TestRakeFileList < Rake::TestCase
29
41
  end
30
42
 
31
43
  def test_create_with_args
32
- fl = FileList.new("testdata/*.c", "x")
33
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
44
+ fl = FileList.new("*.c", "x")
45
+ assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
34
46
  fl.sort
35
47
  end
36
48
 
@@ -40,14 +52,14 @@ class TestRakeFileList < Rake::TestCase
40
52
  end
41
53
 
42
54
  def test_create_with_brackets
43
- fl = FileList["testdata/*.c", "x"]
44
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
55
+ fl = FileList["*.c", "x"]
56
+ assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
45
57
  fl.sort
46
58
  end
47
59
 
48
60
  def test_create_with_brackets_and_filelist
49
- fl = FileList[FileList["testdata/*.c", "x"]]
50
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
61
+ fl = FileList[FileList["*.c", "x"]]
62
+ assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
51
63
  fl.sort
52
64
  end
53
65
 
@@ -57,8 +69,8 @@ class TestRakeFileList < Rake::TestCase
57
69
  end
58
70
 
59
71
  def test_include_with_another_filelist
60
- fl = FileList.new.include(FileList["testdata/*.c", "x"])
61
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
72
+ fl = FileList.new.include(FileList["*.c", "x"])
73
+ assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
62
74
  fl.sort
63
75
  end
64
76
 
@@ -86,86 +98,87 @@ class TestRakeFileList < Rake::TestCase
86
98
 
87
99
  def test_match
88
100
  fl = FileList.new
89
- fl.include('test/test_*.rb')
90
- assert fl.include?("test/test_rake_file_list.rb")
91
- assert fl.size > 3
92
- fl.each { |fn| assert_match(/\.rb$/, fn) }
101
+ fl.include '*.c'
102
+
103
+ assert_equal %w[abc.c x.c xyz.c], fl.sort
93
104
  end
94
105
 
95
106
  def test_add_matching
96
107
  fl = FileList.new
97
108
  fl << "a.java"
98
- fl.include("test/*.rb")
99
- assert_equal "a.java", fl[0]
100
- assert fl.size > 2
101
- assert fl.include?("test/test_rake_file_list.rb")
109
+ fl.include '*.c'
110
+
111
+ assert_equal %w[a.java abc.c x.c xyz.c], fl.sort
102
112
  end
103
113
 
104
114
  def test_multiple_patterns
105
- create_test_data
106
115
  fl = FileList.new
107
- fl.include('*.c', '*xist*')
116
+ fl.include('*.z', '*foo*')
117
+
108
118
  assert_equal [], fl
109
- fl.include('testdata/*.c', 'testdata/*xist*')
110
- assert_equal [
111
- 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c', 'testdata/existing'
112
- ].sort, fl.sort
119
+
120
+ fl.include('*.c', '*xist*')
121
+ assert_equal %w[x.c xyz.c abc.c existing].sort, fl.sort
113
122
  end
114
123
 
115
124
  def test_square_bracket_pattern
116
125
  fl = FileList.new
117
- fl.include("testdata/abc.[ch]")
126
+ fl.include("abc.[ch]")
118
127
  assert fl.size == 2
119
- assert fl.include?("testdata/abc.c")
120
- assert fl.include?("testdata/abc.h")
128
+ assert fl.include?("abc.c")
129
+ assert fl.include?("abc.h")
121
130
  end
122
131
 
123
132
  def test_curly_bracket_pattern
124
133
  fl = FileList.new
125
- fl.include("testdata/abc.{c,h}")
134
+ fl.include("abc.{c,h}")
126
135
  assert fl.size == 2
127
- assert fl.include?("testdata/abc.c")
128
- assert fl.include?("testdata/abc.h")
136
+ assert fl.include?("abc.c")
137
+ assert fl.include?("abc.h")
129
138
  end
130
139
 
131
140
  def test_reject
132
141
  fl = FileList.new
133
- fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
134
- fl.reject! { |fn| fn =~ %r{/x} }
135
- assert_equal [
136
- 'testdata/abc.c', 'testdata/existing'
137
- ], fl
142
+ fl.include %w(x.c abc.c xyz.c existing)
143
+ fl.reject! { |fn| fn =~ /^x/ }
144
+ assert_equal %w[abc.c existing], fl
138
145
  end
139
146
 
140
147
  def test_exclude
141
- fl = FileList['testdata/x.c', 'testdata/abc.c', 'testdata/xyz.c', 'testdata/existing']
148
+ fl = FileList['x.c', 'abc.c', 'xyz.c', 'existing']
142
149
  fl.each { |fn| touch fn, :verbose => false }
143
- x = fl.exclude(%r{/x.+\.})
150
+
151
+ x = fl.exclude(%r{^x.+\.})
152
+
144
153
  assert_equal FileList, x.class
145
- assert_equal %w(testdata/x.c testdata/abc.c testdata/existing), fl
154
+ assert_equal %w(x.c abc.c existing), fl
146
155
  assert_equal fl.object_id, x.object_id
147
- fl.exclude('testdata/*.c')
148
- assert_equal ['testdata/existing'], fl
149
- fl.exclude('testdata/existing')
156
+
157
+ fl.exclude('*.c')
158
+
159
+ assert_equal ['existing'], fl
160
+
161
+ fl.exclude('existing')
162
+
150
163
  assert_equal [], fl
151
164
  end
152
165
 
153
166
  def test_excluding_via_block
154
- fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
167
+ fl = FileList['a.c', 'b.c', 'xyz.c']
155
168
  fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
156
169
  assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
157
- assert_equal ['testdata/a.c', 'testdata/b.c'], fl
170
+ assert_equal ['a.c', 'b.c'], fl
158
171
  end
159
172
 
160
173
  def test_exclude_return_on_create
161
- fl = FileList['testdata/*'].exclude(/.*\.[hcx]$/)
162
- assert_equal ['testdata/existing', 'testdata/cfiles'].sort, fl.sort
174
+ fl = FileList['*'].exclude(/.*\.[hcx]$/)
175
+ assert_equal %w[cfiles existing xyzzy.txt], fl.sort
163
176
  assert_equal FileList, fl.class
164
177
  end
165
178
 
166
179
  def test_exclude_with_string_return_on_create
167
- fl = FileList['testdata/*'].exclude('testdata/abc.c')
168
- assert_equal %w(testdata/existing testdata/cfiles testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c).sort, fl.sort
180
+ fl = FileList['*'].exclude('abc.c')
181
+ assert_equal %w[abc.h abc.x cfiles existing x.c xyz.c xyzzy.txt], fl.sort
169
182
  assert_equal FileList, fl.class
170
183
  end
171
184
 
@@ -173,8 +186,8 @@ class TestRakeFileList < Rake::TestCase
173
186
  fl = FileList.new
174
187
  fl.clear_exclude
175
188
  fl.include("**/*~", "**/*.bak", "**/core")
176
- assert fl.member?("testdata/core"), "Should include core"
177
- assert fl.member?("testdata/x.bak"), "Should include .bak files"
189
+ assert fl.member?("core"), "Should include core"
190
+ assert fl.member?("x.bak"), "Should include .bak files"
178
191
  end
179
192
 
180
193
  def test_unique
@@ -201,54 +214,54 @@ class TestRakeFileList < Rake::TestCase
201
214
  end
202
215
 
203
216
  def test_to_s_pending
204
- fl = FileList['testdata/abc.*']
217
+ fl = FileList['abc.*']
205
218
  result = fl.to_s
206
- assert_match(%r{testdata/abc\.c}, result)
207
- assert_match(%r{testdata/abc\.h}, result)
208
- assert_match(%r{testdata/abc\.x}, result)
209
- assert_match(%r{(testdata/abc\..\b ?){2}}, result)
219
+ assert_match(%r{abc\.c}, result)
220
+ assert_match(%r{abc\.h}, result)
221
+ assert_match(%r{abc\.x}, result)
222
+ assert_match(%r{(abc\..\b ?){2}}, result)
210
223
  end
211
224
 
212
225
  def test_inspect_pending
213
- fl = FileList['testdata/abc.*']
226
+ fl = FileList['abc.*']
214
227
  result = fl.inspect
215
- assert_match(%r{"testdata/abc\.c"}, result)
216
- assert_match(%r{"testdata/abc\.h"}, result)
217
- assert_match(%r{"testdata/abc\.x"}, result)
218
- assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
228
+ assert_match(%r{"abc\.c"}, result)
229
+ assert_match(%r{"abc\.h"}, result)
230
+ assert_match(%r{"abc\.x"}, result)
231
+ assert_match(%r|^\[("abc\..", ){2}"abc\.."\]$|, result)
219
232
  end
220
233
 
221
234
  def test_sub
222
- fl = FileList["testdata/*.c"]
235
+ fl = FileList["*.c"]
223
236
  f2 = fl.sub(/\.c$/, ".o")
224
237
  assert_equal FileList, f2.class
225
- assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
238
+ assert_equal ["abc.o", "x.o", "xyz.o"].sort,
226
239
  f2.sort
227
240
  f3 = fl.gsub(/\.c$/, ".o")
228
241
  assert_equal FileList, f3.class
229
- assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
242
+ assert_equal ["abc.o", "x.o", "xyz.o"].sort,
230
243
  f3.sort
231
244
  end
232
245
 
233
246
  def test_claim_to_be_a_kind_of_array
234
- fl = FileList['testdata/*.c']
247
+ fl = FileList['*.c']
235
248
  assert fl.is_a?(Array)
236
249
  assert fl.kind_of?(Array)
237
250
  end
238
251
 
239
252
  def test_claim_to_be_a_kind_of_filelist
240
- fl = FileList['testdata/*.c']
253
+ fl = FileList['*.c']
241
254
  assert fl.is_a?(FileList)
242
255
  assert fl.kind_of?(FileList)
243
256
  end
244
257
 
245
258
  def test_claim_to_be_a_filelist_instance
246
- fl = FileList['testdata/*.c']
259
+ fl = FileList['*.c']
247
260
  assert fl.instance_of?(FileList)
248
261
  end
249
262
 
250
263
  def test_dont_claim_to_be_an_array_instance
251
- fl = FileList['testdata/*.c']
264
+ fl = FileList['*.c']
252
265
  assert ! fl.instance_of?(Array)
253
266
  end
254
267
 
@@ -304,18 +317,16 @@ class TestRakeFileList < Rake::TestCase
304
317
  end
305
318
 
306
319
  def test_gsub
307
- create_test_data
308
- fl = FileList["testdata/*.c"]
320
+ fl = FileList["*.c"]
309
321
  f2 = fl.gsub(/a/, "A")
310
- assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
322
+ assert_equal ["Abc.c", "x.c", "xyz.c"].sort,
311
323
  f2.sort
312
324
  end
313
325
 
314
326
  def test_gsub!
315
- create_test_data
316
- f = FileList["testdata/*.c"]
327
+ f = FileList["*.c"]
317
328
  f.gsub!(/a/, "A")
318
- assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
329
+ assert_equal ["Abc.c", "x.c", "xyz.c"].sort,
319
330
  f.sort
320
331
  end
321
332
 
@@ -325,66 +336,70 @@ class TestRakeFileList < Rake::TestCase
325
336
  end
326
337
 
327
338
  def test_egrep_with_output
328
- files = FileList['test/test_*.rb']
329
- the_line_number = __LINE__ + 1
330
- out, = capture_io do files.egrep(/PUGH/) end
331
- assert_match(/:#{the_line_number}:/, out)
339
+ files = FileList['*.txt']
340
+
341
+ out, = capture_io do
342
+ files.egrep(/XYZZY/)
343
+ end
344
+
345
+ assert_equal "xyzzy.txt:2:XYZZY\n", out
332
346
  end
333
347
 
334
348
  def test_egrep_with_block
335
- files = FileList['test/test_*.rb']
349
+ files = FileList['*.txt']
336
350
  found = nil
337
- the_line_number = __LINE__ + 1
338
- files.egrep(/XYZZY/) do |fn, ln, line |
351
+
352
+ files.egrep(/XYZZY/) do |fn, ln, line|
339
353
  found = [fn, ln, line]
340
354
  end
341
- assert_equal 'test/test_rake_file_list.rb', found[0]
342
- assert_equal the_line_number, found[1]
343
- assert_match(/files\.egrep/, found[2])
355
+
356
+ assert_equal ["xyzzy.txt", 2, "XYZZY\n"], found
344
357
  end
345
358
 
346
359
  def test_egrep_with_error
347
- files = FileList['test/test_*.rb']
360
+ files = FileList['*.txt']
361
+
348
362
  _, err = capture_io do
349
- files.egrep(/ANYTHING/) do |fn, ln, line |
350
- fail "_EGREP_FAILURE_"
363
+ files.egrep(/XYZZY/) do |fn, ln, line |
364
+ raise "_EGREP_FAILURE_"
351
365
  end
352
366
  end
353
- assert_match(/_EGREP_FAILURE_/, err)
367
+
368
+ assert_equal "Error while processing 'xyzzy.txt': _EGREP_FAILURE_\n", err
354
369
  end
355
370
 
356
371
  def test_existing
357
- fl = FileList['testdata/abc.c', 'testdata/notthere.c']
358
- assert_equal ["testdata/abc.c"], fl.existing
372
+ fl = FileList['abc.c', 'notthere.c']
373
+ assert_equal ["abc.c"], fl.existing
359
374
  assert fl.existing.is_a?(FileList)
360
375
  end
361
376
 
362
377
  def test_existing!
363
- fl = FileList['testdata/abc.c', 'testdata/notthere.c']
378
+ fl = FileList['abc.c', 'notthere.c']
364
379
  result = fl.existing!
365
- assert_equal ["testdata/abc.c"], fl
380
+ assert_equal ["abc.c"], fl
366
381
  assert_equal fl.object_id, result.object_id
367
382
  end
368
383
 
369
384
  def test_ignore_special
370
- f = FileList['testdata/*']
371
- assert ! f.include?("testdata/CVS"), "Should not contain CVS"
372
- assert ! f.include?("testdata/.svn"), "Should not contain .svn"
373
- assert ! f.include?("testdata/.dummy"), "Should not contain dot files"
374
- assert ! f.include?("testdata/x.bak"), "Should not contain .bak files"
375
- assert ! f.include?("testdata/x~"), "Should not contain ~ files"
376
- assert ! f.include?("testdata/core"), "Should not contain core files"
385
+ f = FileList['*']
386
+ assert ! f.include?("CVS"), "Should not contain CVS"
387
+ assert ! f.include?(".svn"), "Should not contain .svn"
388
+ assert ! f.include?(".dummy"), "Should not contain dot files"
389
+ assert ! f.include?("x.bak"), "Should not contain .bak files"
390
+ assert ! f.include?("x~"), "Should not contain ~ files"
391
+ assert ! f.include?("core"), "Should not contain core files"
377
392
  end
378
393
 
379
394
  def test_clear_ignore_patterns
380
- f = FileList['testdata/*', 'testdata/.svn']
395
+ f = FileList['*', '.svn']
381
396
  f.clear_exclude
382
- assert f.include?("testdata/abc.c")
383
- assert f.include?("testdata/xyz.c")
384
- assert f.include?("testdata/CVS")
385
- assert f.include?("testdata/.svn")
386
- assert f.include?("testdata/x.bak")
387
- assert f.include?("testdata/x~")
397
+ assert f.include?("abc.c")
398
+ assert f.include?("xyz.c")
399
+ assert f.include?("CVS")
400
+ assert f.include?(".svn")
401
+ assert f.include?("x.bak")
402
+ assert f.include?("x~")
388
403
  end
389
404
 
390
405
  def test_exclude_with_alternate_file_seps
@@ -422,8 +437,8 @@ class TestRakeFileList < Rake::TestCase
422
437
  end
423
438
 
424
439
  def test_flatten
425
- assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
426
- ['a', FileList['testdata/*.c']].flatten.sort
440
+ assert_equal ['a', 'x.c', 'xyz.c', 'abc.c'].sort,
441
+ ['a', FileList['*.c']].flatten.sort
427
442
  end
428
443
 
429
444
  def test_clone_and_dup
@@ -600,7 +615,7 @@ class TestRakeFileList < Rake::TestCase
600
615
  end
601
616
 
602
617
  def test_file_utils_can_use_filelists
603
- cfiles = FileList['testdata/*.c']
618
+ cfiles = FileList['*.c']
604
619
 
605
620
  cp cfiles, @cdir, :verbose => false
606
621
 
@@ -609,25 +624,5 @@ class TestRakeFileList < Rake::TestCase
609
624
  assert File.exist?(File.join(@cdir, 'x.c'))
610
625
  end
611
626
 
612
- def create_test_data
613
- verbose(false) do
614
-
615
- mkdir "testdata" unless File.exist? "testdata"
616
- mkdir "testdata/CVS" rescue nil
617
- mkdir "testdata/.svn" rescue nil
618
- @cdir = "testdata/cfiles"
619
- mkdir @cdir rescue nil
620
- touch "testdata/.dummy"
621
- touch "testdata/x.bak"
622
- touch "testdata/x~"
623
- touch "testdata/core"
624
- touch "testdata/x.c"
625
- touch "testdata/xyz.c"
626
- touch "testdata/abc.c"
627
- touch "testdata/abc.h"
628
- touch "testdata/abc.x"
629
- touch "testdata/existing"
630
- end
631
- end
632
-
633
627
  end
628
+