rake 0.4.8
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 +132 -0
- data/MIT-LICENSE +21 -0
- data/README +209 -0
- data/Rakefile +215 -0
- data/TODO +19 -0
- data/bin/rake +8 -0
- data/doc/example/Rakefile1 +38 -0
- data/doc/example/Rakefile2 +35 -0
- data/doc/example/a.c +6 -0
- data/doc/example/b.c +6 -0
- data/doc/example/main.c +11 -0
- data/doc/glossary.rdoc +51 -0
- data/doc/proto_rake.rdoc +127 -0
- data/doc/rakefile.rdoc +234 -0
- data/doc/rational.rdoc +151 -0
- data/install.rb +88 -0
- data/lib/rake.rb +983 -0
- data/lib/rake/clean.rb +31 -0
- data/lib/rake/contrib/compositepublisher.rb +24 -0
- data/lib/rake/contrib/ftptools.rb +139 -0
- data/lib/rake/contrib/publisher.rb +75 -0
- data/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/lib/rake/contrib/sshpublisher.rb +47 -0
- data/lib/rake/contrib/sys.rb +207 -0
- data/lib/rake/gempackagetask.rb +98 -0
- data/lib/rake/packagetask.rb +152 -0
- data/lib/rake/rdoctask.rb +128 -0
- data/lib/rake/runtest.rb +23 -0
- data/lib/rake/tasklib.rb +24 -0
- data/lib/rake/testtask.rb +118 -0
- data/test/contrib/testsys.rb +47 -0
- data/test/data/rbext/rakefile.rb +3 -0
- data/test/filecreation.rb +26 -0
- data/test/functional.rb +82 -0
- data/test/testclean.rb +13 -0
- data/test/testfilelist.rb +255 -0
- data/test/testfileutils.rb +55 -0
- data/test/testftp.rb +55 -0
- data/test/testpackagetask.rb +81 -0
- data/test/testtasks.rb +371 -0
- data/test/testtesttask.rb +71 -0
- metadata +91 -0
data/test/testftp.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rake/contrib/ftptools'
|
6
|
+
|
7
|
+
class FakeDate
|
8
|
+
def self.today
|
9
|
+
Date.new(2003,10,3)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
class TestFtpFile < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def setup
|
17
|
+
Rake::FtpFile.class_eval { @date_class = FakeDate }
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_general
|
21
|
+
file = Rake::FtpFile.new("here", "-rw-r--r-- 1 a279376 develop 121770 Mar 6 14:50 wiki.pl")
|
22
|
+
assert_equal "wiki.pl", file.name
|
23
|
+
assert_equal "here/wiki.pl", file.path
|
24
|
+
assert_equal "a279376", file.owner
|
25
|
+
assert_equal "develop", file.group
|
26
|
+
assert_equal 0644, file.mode
|
27
|
+
assert_equal 121770, file.size
|
28
|
+
assert_equal Time.mktime(2003,3,6,14,50,0,0), file.time
|
29
|
+
assert ! file.directory?
|
30
|
+
assert ! file.symlink?
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_far_date
|
34
|
+
file = Rake::FtpFile.new(".", "drwxr-xr-x 3 a279376 develop 4096 Nov 26 2001 vss")
|
35
|
+
assert_equal Time.mktime(2001,11,26,0,0,0,0), file.time
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_close_date
|
39
|
+
file = Rake::FtpFile.new(".", "drwxr-xr-x 3 a279376 develop 4096 Nov 26 15:35 vss")
|
40
|
+
assert_equal Time.mktime(2002,11,26,15,35,0,0), file.time
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_directory
|
44
|
+
file = Rake::FtpFile.new(".", "drwxrwxr-x 9 a279376 develop 4096 Mar 13 14:32 working")
|
45
|
+
assert file.directory?
|
46
|
+
assert !file.symlink?
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_symlink
|
50
|
+
file = Rake::FtpFile.new(".", "lrwxrwxrwx 1 a279376 develop 64 Mar 26 2002 xtrac -> /home/a279376/working/ics/development/java/com/fmr/fwp/ics/xtrac")
|
51
|
+
assert_equal 'xtrac', file.name
|
52
|
+
assert file.symlink?
|
53
|
+
assert !file.directory?
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake/packagetask'
|
5
|
+
|
6
|
+
class TestPackageTask < Test::Unit::TestCase
|
7
|
+
def test_create
|
8
|
+
pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
|
9
|
+
p.package_files << "install.rb"
|
10
|
+
p.package_files.include(
|
11
|
+
'[A-Z]*',
|
12
|
+
'bin/**/*',
|
13
|
+
'lib/**/*.rb',
|
14
|
+
'test/**/*.rb',
|
15
|
+
'doc/**/*',
|
16
|
+
'build/rubyapp.rb',
|
17
|
+
'*.blurb')
|
18
|
+
p.package_files.exclude(/\bCVS\b/)
|
19
|
+
p.package_files.exclude(/~$/)
|
20
|
+
p.package_dir = 'pkg'
|
21
|
+
p.need_tar = true
|
22
|
+
p.need_zip = true
|
23
|
+
}
|
24
|
+
assert_equal "pkg", pkg.package_dir
|
25
|
+
assert pkg.package_files.include?("bin/rake")
|
26
|
+
assert "pkgr", pkg.name
|
27
|
+
assert "1.2.3", pkg.version
|
28
|
+
assert Task[:package]
|
29
|
+
assert Task['pkg/pkgr-1.2.3.tgz']
|
30
|
+
assert Task['pkg/pkgr-1.2.3.zip']
|
31
|
+
assert Task["pkg/pkgr-1.2.3"]
|
32
|
+
assert Task[:clobber_package]
|
33
|
+
assert Task[:repackage]
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_missing_version
|
37
|
+
assert_raises(RuntimeError) {
|
38
|
+
pkg = Rake::PackageTask.new("pkgr") { |p| }
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_no_version
|
43
|
+
pkg = Rake::PackageTask.new("pkgr", :noversion) { |p| }
|
44
|
+
assert "pkgr", pkg.send(:package_name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_clone
|
48
|
+
pkg = Rake::PackageTask.new("x", :noversion)
|
49
|
+
p2 = pkg.clone
|
50
|
+
pkg.package_files << "y"
|
51
|
+
p2.package_files << "x"
|
52
|
+
assert_equal ["y"], pkg.package_files
|
53
|
+
assert_equal ["x"], p2.package_files
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
begin
|
59
|
+
require 'rubygems'
|
60
|
+
require 'rake/gempackagetask'
|
61
|
+
rescue Exception
|
62
|
+
puts "WARNING: RubyGems not installed"
|
63
|
+
end
|
64
|
+
|
65
|
+
if ! defined?(Gem)
|
66
|
+
puts "WARNING: Unable to test GemPackaging ... requires RubyGems"
|
67
|
+
else
|
68
|
+
class TestGemPackageTask < Test::Unit::TestCase
|
69
|
+
def test_gem_package
|
70
|
+
gem = Gem::Specification.new do |g|
|
71
|
+
g.name = "pkgr"
|
72
|
+
g.version = "1.2.3"
|
73
|
+
g.files = FileList["x"].resolve
|
74
|
+
end
|
75
|
+
pkg = Rake::GemPackageTask.new(gem) do |p|
|
76
|
+
p.package_files << "y"
|
77
|
+
end
|
78
|
+
assert_equal ["x", "y"], pkg.package_files
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/test/testtasks.rb
ADDED
@@ -0,0 +1,371 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rake'
|
6
|
+
require 'test/filecreation'
|
7
|
+
|
8
|
+
######################################################################
|
9
|
+
class TestTask < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
Task.clear
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_create
|
15
|
+
arg = nil
|
16
|
+
t = Task.lookup(:name).enhance { |task| arg = task; 1234 }
|
17
|
+
assert_equal "name", t.name
|
18
|
+
assert [], t.prerequisites
|
19
|
+
assert t.needed?
|
20
|
+
t.execute
|
21
|
+
assert_equal t, arg
|
22
|
+
assert_nil t.source
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_invoke
|
26
|
+
runlist = []
|
27
|
+
t1 = Task.lookup(:t1).enhance([:t2, :t3]) { |t| runlist << t.name; 3321 }
|
28
|
+
t2 = Task.lookup(:t2).enhance { |t| runlist << t.name }
|
29
|
+
t3 = Task.lookup(:t3).enhance { |t| runlist << t.name }
|
30
|
+
assert_equal [:t2, :t3], t1.prerequisites
|
31
|
+
t1.invoke
|
32
|
+
assert_equal ["t2", "t3", "t1"], runlist
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_no_double_invoke
|
36
|
+
runlist = []
|
37
|
+
t1 = Task.lookup(:t1).enhance([:t2, :t3]) { |t| runlist << t.name; 3321 }
|
38
|
+
t2 = Task.lookup(:t2).enhance([:t3]) { |t| runlist << t.name }
|
39
|
+
t3 = Task.lookup(:t3).enhance { |t| runlist << t.name }
|
40
|
+
t1.invoke
|
41
|
+
assert_equal ["t3", "t2", "t1"], runlist
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_find
|
45
|
+
task :tfind
|
46
|
+
assert_equal "tfind", Task[:tfind].name
|
47
|
+
ex = assert_raises(RuntimeError) { Task[:leaves] }
|
48
|
+
assert_equal "Don't know how to rake leaves", ex.message
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_defined
|
52
|
+
assert ! Task.task_defined?(:a)
|
53
|
+
task :a
|
54
|
+
assert Task.task_defined?(:a)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_multi_invocations
|
58
|
+
runs = []
|
59
|
+
p = proc do |t| runs << t.name end
|
60
|
+
task({:t1=>[:t2,:t3]}, &p)
|
61
|
+
task({:t2=>[:t3]}, &p)
|
62
|
+
task(:t3, &p)
|
63
|
+
Task[:t1].invoke
|
64
|
+
assert_equal ["t1", "t2", "t3"], runs.sort
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_task_list
|
68
|
+
task :t2
|
69
|
+
task :t1 => [:t2]
|
70
|
+
assert_equal ["t1", "t2"], Task.tasks.collect {|t| t.name}
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
######################################################################
|
76
|
+
class TestFileTask < Test::Unit::TestCase
|
77
|
+
include FileCreation
|
78
|
+
|
79
|
+
def setup
|
80
|
+
Task.clear
|
81
|
+
@runs = Array.new
|
82
|
+
FileUtils.rm_f NEWFILE
|
83
|
+
FileUtils.rm_f OLDFILE
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_file_need
|
87
|
+
name = "testdata/dummy"
|
88
|
+
file name
|
89
|
+
ftask = Task[name]
|
90
|
+
assert_equal name.to_s, ftask.name
|
91
|
+
File.delete(ftask.name) rescue nil
|
92
|
+
assert ftask.needed?, "file should be needed"
|
93
|
+
open(ftask.name, "w") { |f| f.puts "HI" }
|
94
|
+
assert_equal nil, ftask.prerequisites.collect{|n| Task[n].timestamp}.max
|
95
|
+
assert ! ftask.needed?, "file should not be needed"
|
96
|
+
File.delete(ftask.name) rescue nil
|
97
|
+
end
|
98
|
+
|
99
|
+
OLDFILE = "testdata/old"
|
100
|
+
NEWFILE = "testdata/new"
|
101
|
+
|
102
|
+
def test_file_times_new_depends_on_old
|
103
|
+
create_timed_files(OLDFILE, NEWFILE)
|
104
|
+
|
105
|
+
t1 = FileTask.lookup(NEWFILE).enhance([OLDFILE])
|
106
|
+
t2 = FileTask.lookup(OLDFILE)
|
107
|
+
assert ! t2.needed?, "Should not need to build old file"
|
108
|
+
assert ! t1.needed?, "Should not need to rebuild new file because of old"
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_file_times_old_depends_on_new
|
112
|
+
create_timed_files(OLDFILE, NEWFILE)
|
113
|
+
|
114
|
+
t1 = FileTask.lookup(OLDFILE).enhance([NEWFILE])
|
115
|
+
t2 = FileTask.lookup(NEWFILE)
|
116
|
+
assert ! t2.needed?, "Should not need to build new file"
|
117
|
+
preq_stamp = t1.prerequisites.collect{|t| Task[t].timestamp}.max
|
118
|
+
assert_equal t2.timestamp, preq_stamp
|
119
|
+
assert t1.timestamp < preq_stamp, "T1 should be older"
|
120
|
+
assert t1.needed?, "Should need to rebuild old file because of new"
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_file_depends_on_task_depend_on_file
|
124
|
+
create_timed_files(OLDFILE, NEWFILE)
|
125
|
+
|
126
|
+
file NEWFILE => [:obj] do |t| @runs << t.name end
|
127
|
+
task :obj => [OLDFILE] do |t| @runs << t.name end
|
128
|
+
file OLDFILE do |t| @runs << t.name end
|
129
|
+
|
130
|
+
Task[:obj].invoke
|
131
|
+
Task[NEWFILE].invoke
|
132
|
+
assert ! @runs.include?(NEWFILE)
|
133
|
+
end
|
134
|
+
|
135
|
+
# I have currently disabled this test. I'm not convinced that
|
136
|
+
# deleting the file target on failure is always the proper thing to
|
137
|
+
# do. I'm willing to hear input on this topic.
|
138
|
+
def ztest_file_deletes_on_failure
|
139
|
+
task :obj
|
140
|
+
file NEWFILE => [:obj] do |t|
|
141
|
+
FileUtils.touch NEWFILE
|
142
|
+
fail "Ooops"
|
143
|
+
end
|
144
|
+
assert Task[NEWFILE]
|
145
|
+
begin
|
146
|
+
Task[NEWFILE].invoke
|
147
|
+
rescue Exception
|
148
|
+
end
|
149
|
+
assert( ! File.exist?(NEWFILE), "NEWFILE should be deleted")
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
######################################################################
|
155
|
+
class TestDirectoryTask < Test::Unit::TestCase
|
156
|
+
def setup
|
157
|
+
rm_rf "testdata", :verbose=>false
|
158
|
+
end
|
159
|
+
|
160
|
+
def teardown
|
161
|
+
rm_rf "testdata", :verbose=>false
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_directory
|
165
|
+
desc "DESC"
|
166
|
+
directory "testdata/a/b/c"
|
167
|
+
assert_equal FileTask, Task["testdata"].class
|
168
|
+
assert_equal FileTask, Task["testdata/a"].class
|
169
|
+
assert_equal FileTask, Task["testdata/a/b/c"].class
|
170
|
+
assert_nil Task["testdata"].comment
|
171
|
+
assert_equal "DESC", Task["testdata/a/b/c"].comment
|
172
|
+
assert_nil Task["testdata/a/b"].comment
|
173
|
+
verbose(false) {
|
174
|
+
Task['testdata/a/b'].invoke
|
175
|
+
}
|
176
|
+
assert File.exist?("testdata/a/b")
|
177
|
+
assert ! File.exist?("testdata/a/b/c")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
__END__
|
182
|
+
|
183
|
+
######################################################################
|
184
|
+
class TestDefinitions < Test::Unit::TestCase
|
185
|
+
EXISTINGFILE = "testdata/existing"
|
186
|
+
|
187
|
+
def setup
|
188
|
+
Task.clear
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_task
|
192
|
+
done = false
|
193
|
+
task :one => [:two] do done = true end
|
194
|
+
task :two
|
195
|
+
task :three => [:one, :two]
|
196
|
+
check_tasks(:one, :two, :three)
|
197
|
+
assert done, "Should be done"
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_file_task
|
201
|
+
done = false
|
202
|
+
file "testdata/one" => "testdata/two" do done = true end
|
203
|
+
file "testdata/two"
|
204
|
+
file "testdata/three" => ["testdata/one", "testdata/two"]
|
205
|
+
check_tasks("testdata/one", "testdata/two", "testdata/three")
|
206
|
+
assert done, "Should be done"
|
207
|
+
end
|
208
|
+
|
209
|
+
def check_tasks(n1, n2, n3)
|
210
|
+
t = Task[n1]
|
211
|
+
assert Task === t, "Should be a Task"
|
212
|
+
assert_equal n1.to_s, t.name
|
213
|
+
assert_equal [n2.to_s], t.prerequisites.collect{|n| n.to_s}
|
214
|
+
t.invoke
|
215
|
+
t2 = Task[n2]
|
216
|
+
assert_equal [], t2.prerequisites
|
217
|
+
t3 = Task[n3]
|
218
|
+
assert_equal [n1.to_s, n2.to_s], t3.prerequisites.collect{|n|n.to_s}
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_incremental_definitions
|
222
|
+
runs = []
|
223
|
+
task :t1 => [:t2] do runs << "A"; 4321 end
|
224
|
+
task :t1 => [:t3] do runs << "B"; 1234 end
|
225
|
+
task :t1 => [:t3]
|
226
|
+
task :t2
|
227
|
+
task :t3
|
228
|
+
Task[:t1].invoke
|
229
|
+
assert_equal ["A", "B"], runs
|
230
|
+
assert_equal ["t2", "t3"], Task[:t1].prerequisites
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_missing_dependencies
|
234
|
+
task :x => ["testdata/missing"]
|
235
|
+
assert_raises(RuntimeError) { Task[:x].invoke }
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_implicit_file_dependencies
|
239
|
+
runs = []
|
240
|
+
create_existing_file
|
241
|
+
task :y => [EXISTINGFILE] do |t| runs << t.name end
|
242
|
+
Task[:y].invoke
|
243
|
+
assert_equal runs, ['y']
|
244
|
+
end
|
245
|
+
|
246
|
+
private # ----------------------------------------------------------
|
247
|
+
|
248
|
+
def create_existing_file
|
249
|
+
if ! File.exist?(EXISTINGFILE)
|
250
|
+
open(EXISTINGFILE, "w") do |f| f.puts "HI" end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|
255
|
+
|
256
|
+
######################################################################
|
257
|
+
class TestRules < Test::Unit::TestCase
|
258
|
+
include FileCreation
|
259
|
+
|
260
|
+
SRCFILE = "testdata/abc.c"
|
261
|
+
SRCFILE2 = "testdata/xyz.c"
|
262
|
+
FTNFILE = "testdata/abc.f"
|
263
|
+
OBJFILE = "testdata/abc.o"
|
264
|
+
|
265
|
+
def setup
|
266
|
+
Task.clear
|
267
|
+
@runs = []
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_multiple_rules1
|
271
|
+
create_file(FTNFILE)
|
272
|
+
delete_file(SRCFILE)
|
273
|
+
delete_file(OBJFILE)
|
274
|
+
rule /\.o$/ => ['.c'] do @runs << :C end
|
275
|
+
rule /\.o$/ => ['.f'] do @runs << :F end
|
276
|
+
t = Task[OBJFILE]
|
277
|
+
t.invoke
|
278
|
+
Task[OBJFILE].invoke
|
279
|
+
assert_equal [:F], @runs
|
280
|
+
end
|
281
|
+
|
282
|
+
def test_multiple_rules2
|
283
|
+
create_file(FTNFILE)
|
284
|
+
delete_file(SRCFILE)
|
285
|
+
delete_file(OBJFILE)
|
286
|
+
rule /\.o$/ => ['.f'] do @runs << :F end
|
287
|
+
rule /\.o$/ => ['.c'] do @runs << :C end
|
288
|
+
Task[OBJFILE].invoke
|
289
|
+
assert_equal [:F], @runs
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_create_with_source
|
293
|
+
create_file(SRCFILE)
|
294
|
+
rule /\.o$/ => ['.c'] do |t|
|
295
|
+
@runs << t.name
|
296
|
+
assert_equal OBJFILE, t.name
|
297
|
+
assert_equal SRCFILE, t.source
|
298
|
+
end
|
299
|
+
Task[OBJFILE].invoke
|
300
|
+
assert_equal [OBJFILE], @runs
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_single_dependent
|
304
|
+
create_file(SRCFILE)
|
305
|
+
rule /\.o$/ => '.c' do |t|
|
306
|
+
@runs << t.name
|
307
|
+
end
|
308
|
+
Task[OBJFILE].invoke
|
309
|
+
assert_equal [OBJFILE], @runs
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_create_by_string
|
313
|
+
create_file(SRCFILE)
|
314
|
+
rule '.o' => ['.c'] do |t|
|
315
|
+
@runs << t.name
|
316
|
+
end
|
317
|
+
Task[OBJFILE].invoke
|
318
|
+
assert_equal [OBJFILE], @runs
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_rule_and_no_action_task
|
322
|
+
create_file(SRCFILE)
|
323
|
+
create_file(SRCFILE2)
|
324
|
+
delete_file(OBJFILE)
|
325
|
+
rule '.o' => '.c' do |t|
|
326
|
+
@runs << t.source
|
327
|
+
end
|
328
|
+
file OBJFILE => [SRCFILE2]
|
329
|
+
Task[OBJFILE].invoke
|
330
|
+
assert_equal [SRCFILE], @runs
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_string_close_matches
|
334
|
+
create_file("testdata/x.c")
|
335
|
+
rule '.o' => ['.c'] do |t|
|
336
|
+
@runs << t.name
|
337
|
+
end
|
338
|
+
assert_raises(RuntimeError) { Task['testdata/x.obj'].invoke }
|
339
|
+
assert_raises(RuntimeError) { Task['testdata/x.xyo'].invoke }
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_precedence_rule_vs_implicit
|
343
|
+
create_timed_files(OBJFILE, SRCFILE)
|
344
|
+
rule /\.o$/ => ['.c'] do
|
345
|
+
@runs << :RULE
|
346
|
+
end
|
347
|
+
Task[OBJFILE].invoke
|
348
|
+
assert_equal [:RULE], @runs
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_too_many_dependents
|
352
|
+
assert_raises(RuntimeError) { rule '.o' => ['.c', '.cpp'] }
|
353
|
+
end
|
354
|
+
|
355
|
+
def test_proc_dependent
|
356
|
+
ran = false
|
357
|
+
File.makedirs("testdata/src/jw")
|
358
|
+
create_file("testdata/src/jw/X.java")
|
359
|
+
rule %r(classes/.*\.class) => [
|
360
|
+
proc { |fn| fn.sub(/^classes/, 'testdata/src').sub(/\.class$/, '.java') }
|
361
|
+
] do |task|
|
362
|
+
assert_equal task.name, 'classes/jw/X.class'
|
363
|
+
assert_equal task.source, 'testdata/src/jw/X.java'
|
364
|
+
ran = true
|
365
|
+
end
|
366
|
+
Task['classes/jw/X.class'].invoke
|
367
|
+
assert ran, "Should have triggered rule"
|
368
|
+
ensure
|
369
|
+
rm_r("testdata/src", :verbose=>false) rescue nil
|
370
|
+
end
|
371
|
+
end
|