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.
- data/CHANGES +13 -0
- data/README.rdoc +12 -15
- data/Rakefile +8 -44
- data/bin/rake +1 -0
- data/lib/rake.rb +4 -0
- data/lib/rake/application.rb +9 -3
- data/lib/rake/classic_namespace.rb +2 -0
- data/lib/rake/clean.rb +1 -0
- data/lib/rake/contrib/publisher.rb +10 -6
- data/lib/rake/contrib/sshpublisher.rb +5 -0
- data/lib/rake/dsl_definition.rb +13 -4
- data/lib/rake/ext/time.rb +3 -3
- data/lib/rake/file_utils.rb +9 -7
- data/lib/rake/file_utils_ext.rb +4 -1
- data/lib/rake/gempackagetask.rb +2 -0
- data/lib/rake/rake_test_loader.rb +15 -6
- data/lib/rake/rdoctask.rb +5 -1
- data/lib/rake/task_arguments.rb +4 -0
- data/lib/rake/version.rb +5 -7
- data/test/file_creation.rb +2 -2
- data/test/helper.rb +460 -12
- data/test/test_rake.rb +3 -1
- data/test/test_rake_application.rb +250 -125
- data/test/test_rake_application_options.rb +146 -193
- data/test/test_rake_clean.rb +2 -0
- data/test/test_rake_definitions.rb +6 -6
- data/test/test_rake_directory_task.rb +26 -35
- data/test/test_rake_dsl.rb +4 -0
- data/test/test_rake_file_creation_task.rb +1 -7
- data/test/test_rake_file_list.rb +128 -133
- data/test/test_rake_file_task.rb +1 -3
- data/test/test_rake_file_utils.rb +123 -70
- data/test/test_rake_functional.rb +234 -252
- data/test/test_rake_makefile_loader.rb +22 -1
- data/test/test_rake_package_task.rb +10 -9
- data/test/test_rake_path_map_explode.rb +3 -0
- data/test/test_rake_pseudo_status.rb +3 -2
- data/test/test_rake_rake_test_loader.rb +21 -0
- data/test/test_rake_rdoc_task.rb +5 -3
- data/test/test_rake_require.rb +8 -3
- data/test/test_rake_rules.rb +56 -75
- data/test/test_rake_task.rb +5 -9
- data/test/test_rake_task_argument_parsing.rb +33 -46
- data/test/test_rake_task_arguments.rb +2 -0
- data/test/test_rake_task_manager.rb +12 -0
- data/test/test_rake_task_with_arguments.rb +11 -0
- data/test/test_rake_test_task.rb +55 -57
- data/test/test_rake_top_level_functions.rb +52 -17
- data/test/test_rake_win32.rb +31 -42
- metadata +6 -52
- data/RRR +0 -9
- data/test/check_expansion.rb +0 -5
- data/test/check_no_expansion.rb +0 -5
- data/test/data/access/Rakefile +0 -35
- data/test/data/chains/Rakefile +0 -15
- data/test/data/comments/Rakefile +0 -18
- data/test/data/default/Rakefile +0 -17
- data/test/data/deprecated_import/Rakefile +0 -1
- data/test/data/dryrun/Rakefile +0 -22
- data/test/data/extra/Rakefile +0 -1
- data/test/data/file_creation_task/Rakefile +0 -31
- data/test/data/imports/Rakefile +0 -19
- data/test/data/imports/deps.mf +0 -1
- data/test/data/multidesc/Rakefile +0 -15
- data/test/data/namespace/Rakefile +0 -64
- data/test/data/rakelib/test1.rb +0 -4
- data/test/data/rbext/rakefile.rb +0 -3
- data/test/data/sample.mf +0 -14
- data/test/data/statusreturn/Rakefile +0 -6
- data/test/data/unittest/Rakefile +0 -1
- data/test/data/verbose/Rakefile +0 -34
- data/test/in_environment.rb +0 -35
- data/test/reqfile.rb +0 -3
- data/test/reqfile2.rb +0 -3
- data/test/shellcommand.rb +0 -3
data/test/test_rake_clean.rb
CHANGED
@@ -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 = "
|
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 "
|
27
|
-
file "
|
28
|
-
file "
|
29
|
-
check_tasks("
|
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 => ["
|
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
|
8
|
-
|
7
|
+
def test_directory
|
8
|
+
desc "DESC"
|
9
9
|
|
10
|
-
|
11
|
-
end
|
10
|
+
directory "a/b/c"
|
12
11
|
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
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['
|
21
|
+
Task['a/b'].invoke
|
30
22
|
}
|
31
|
-
|
32
|
-
assert
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
data/test/test_rake_dsl.rb
CHANGED
@@ -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 = '
|
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]
|
data/test/test_rake_file_list.rb
CHANGED
@@ -6,14 +6,26 @@ class TestRakeFileList < Rake::TestCase
|
|
6
6
|
def setup
|
7
7
|
super
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
FileUtils.
|
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("
|
33
|
-
assert_equal ["
|
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["
|
44
|
-
assert_equal ["
|
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["
|
50
|
-
assert_equal ["
|
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["
|
61
|
-
assert_equal ["
|
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
|
90
|
-
|
91
|
-
|
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
|
99
|
-
|
100
|
-
|
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('*.
|
116
|
+
fl.include('*.z', '*foo*')
|
117
|
+
|
108
118
|
assert_equal [], fl
|
109
|
-
|
110
|
-
|
111
|
-
|
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("
|
126
|
+
fl.include("abc.[ch]")
|
118
127
|
assert fl.size == 2
|
119
|
-
assert fl.include?("
|
120
|
-
assert fl.include?("
|
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("
|
134
|
+
fl.include("abc.{c,h}")
|
126
135
|
assert fl.size == 2
|
127
|
-
assert fl.include?("
|
128
|
-
assert fl.include?("
|
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(
|
134
|
-
fl.reject! { |fn| fn =~
|
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['
|
148
|
+
fl = FileList['x.c', 'abc.c', 'xyz.c', 'existing']
|
142
149
|
fl.each { |fn| touch fn, :verbose => false }
|
143
|
-
|
150
|
+
|
151
|
+
x = fl.exclude(%r{^x.+\.})
|
152
|
+
|
144
153
|
assert_equal FileList, x.class
|
145
|
-
assert_equal %w(
|
154
|
+
assert_equal %w(x.c abc.c existing), fl
|
146
155
|
assert_equal fl.object_id, x.object_id
|
147
|
-
|
148
|
-
|
149
|
-
|
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['
|
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 ['
|
170
|
+
assert_equal ['a.c', 'b.c'], fl
|
158
171
|
end
|
159
172
|
|
160
173
|
def test_exclude_return_on_create
|
161
|
-
fl = FileList['
|
162
|
-
assert_equal [
|
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['
|
168
|
-
assert_equal %w
|
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?("
|
177
|
-
assert fl.member?("
|
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['
|
217
|
+
fl = FileList['abc.*']
|
205
218
|
result = fl.to_s
|
206
|
-
assert_match(%r{
|
207
|
-
assert_match(%r{
|
208
|
-
assert_match(%r{
|
209
|
-
assert_match(%r{(
|
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['
|
226
|
+
fl = FileList['abc.*']
|
214
227
|
result = fl.inspect
|
215
|
-
assert_match(%r{"
|
216
|
-
assert_match(%r{"
|
217
|
-
assert_match(%r{"
|
218
|
-
assert_match(%r|^\[("
|
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["
|
235
|
+
fl = FileList["*.c"]
|
223
236
|
f2 = fl.sub(/\.c$/, ".o")
|
224
237
|
assert_equal FileList, f2.class
|
225
|
-
assert_equal ["
|
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 ["
|
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['
|
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['
|
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['
|
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['
|
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
|
-
|
308
|
-
fl = FileList["testdata/*.c"]
|
320
|
+
fl = FileList["*.c"]
|
309
321
|
f2 = fl.gsub(/a/, "A")
|
310
|
-
assert_equal ["
|
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
|
-
|
316
|
-
f = FileList["testdata/*.c"]
|
327
|
+
f = FileList["*.c"]
|
317
328
|
f.gsub!(/a/, "A")
|
318
|
-
assert_equal ["
|
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['
|
329
|
-
|
330
|
-
out, = capture_io do
|
331
|
-
|
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['
|
349
|
+
files = FileList['*.txt']
|
336
350
|
found = nil
|
337
|
-
|
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
|
-
|
342
|
-
assert_equal
|
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['
|
360
|
+
files = FileList['*.txt']
|
361
|
+
|
348
362
|
_, err = capture_io do
|
349
|
-
files.egrep(/
|
350
|
-
|
363
|
+
files.egrep(/XYZZY/) do |fn, ln, line |
|
364
|
+
raise "_EGREP_FAILURE_"
|
351
365
|
end
|
352
366
|
end
|
353
|
-
|
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['
|
358
|
-
assert_equal ["
|
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['
|
378
|
+
fl = FileList['abc.c', 'notthere.c']
|
364
379
|
result = fl.existing!
|
365
|
-
assert_equal ["
|
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['
|
371
|
-
assert ! f.include?("
|
372
|
-
assert ! f.include?("
|
373
|
-
assert ! f.include?("
|
374
|
-
assert ! f.include?("
|
375
|
-
assert ! f.include?("
|
376
|
-
assert ! f.include?("
|
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['
|
395
|
+
f = FileList['*', '.svn']
|
381
396
|
f.clear_exclude
|
382
|
-
assert f.include?("
|
383
|
-
assert f.include?("
|
384
|
-
assert f.include?("
|
385
|
-
assert f.include?("
|
386
|
-
assert f.include?("
|
387
|
-
assert f.include?("
|
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', '
|
426
|
-
['a', FileList['
|
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['
|
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
|
+
|